The sweeping victory of President Anwar Sadat's National Democratic Party in last week's parliamentary elections has nearly eliminated his legal opposition and solidified his unchallenged control over Egypt's political and governmental institutions.

All Sadat's associates, personal advisers and Cabinet ministers who ran for seats in the People's Assembly were elected. Several people who occasionally made trouble for Sadat in the previous parliament were defeated.

Complete results are unavailable because runoff elections will be required for at least 80 seats where no candidate obtained a majority. Projections based on initial results, however, showed that Sadat's party could take about 320 of the 382 contested seats. In any case, it is clear that hardly anyone in the new parliament can be regarded as a credible opponent of any Sadat's major policies.

Sadat already has handpicked loyalists running most of Eygpt's major insitutions, including the Army, the universities, Al-Azhar Mosque, the Suez Canal, the newspapers and the provincial administrations. With the National Democratic Party, established only last year, now in unchallenged control of the parliament, Sadat's political strength appears to be greater than at any time since the 1973 war.

Although Sadat is unpopular with some segments of Egypt's intelligentsia, with the left and with the growing ranks of islamic fundamentalists, those groups are outside the mainstream of Egyptian life and lack of the organization of numbers to challenge the president's power.

Egyptians say the National Democratic Party's success can be attributed to Sadat's popularity after Egypt regained more territory from Israel after the peace treaty, to a 7,000-year tradition of popular acceptance of whatever authority is in power, and to a determined effort by the party and government to ensure that the outcome of the election would be satisfactory.

That meant certain key individuals such asPrice Minister Mustafa Khalil had to win and that certain other such as leftist party leader Khaled Mohieddin had to lose.

They did.

Mohieddin, Marxist leader of the Unionist Progressive Party and an outspoken opponent of many Sadat policies, was officially reported to have lost by more than 5,000 votes after Cairo newspapers had already reported his reelection. The party lost its two seats in parliament when none of its 31 candidates was elected.

Sadat's chief of staff, Hassen Kamel, was elected along with the president's close friend, Osman Ahmed Osman, a millionaire contractor; presidential confidant Sayed Marei; and the ministers of social affairs, justice, interior, local government and housing.

The victory of Housing Minister Mustafa Hefnawi, a political newcomer, over a popular and effective incumbent, former finance minister Ahmed Abu Ismail, by some 250 votes of more than 40,000 cast in an obscure district in the Nile Delta, shows the determination of the party to control as many seats as possible even when the opposition, like Abu Ismail, was loyal opposition. He supported the peace treaty but ran in this election as an independen. Of nearly 1,000 independents among the 1,682 candidates for 382 seats, only a few were elected.

This was Egypt's first multiparty election since the 1952 revolution. All parties other than the Arab Solialist Union Created by Gamal Abdel Nasser were banned until 1976, when Sadat opened the door to independent parties. The election enables Sadat to claim that the Egyptian public, given a choice for the first time, endorsed the party that represents his policies.

The actual situation is not quite so clear-cut. Organizations that represent real dissent from Sadat's policies such as the Communists, the Moslem Brotherhood and a prerevolutionary nationalist party known as the Wafd were banned from the elections. Even the legal opposition, led by the Socialist Workers Party, encountered heavy-handed government tactics that limited its ability to mount an effective campaign.

It thus no surprise that the number of opposition seats in the parliament declined.

Still, most Egyptians do support Sadat and favor his policies. It is probably fair to say, as a veteran Egyptian journalists did the other day, that Sadat is in better political shape in this country than either of his partners in the peace process, Prime Minister Menachem Begin or President Carter, in theirs.

Egyptian officials are sensitive to the suggestion that the country's economic difficulties might provoke some kind of anti-Sadat uprising or Iranian style revolution if the peace treaty does not bring the anticipated prosperity to the long-suffering Egyptian masses. They are particularly irritated when the "how long can Sadat last" question comes from Israelis, who wonder whether Eygpt's peace policies would survive the downfall of the president.

But the elections show that Sadat is in firm control and is just determined to root out dissent in the country's legal institutions as he was taken it erupted on the streets in the 1977 bread riots. CAPTION: Picture, Egyptian voters receive ballots for last week's parliamentary election, the first of its kind since 1952. AP