Viewed from Egypt, the last two weeks that proved so turbulent and trying for U.S. diplomacy in the Middle East have been good ones for President Anwar Sadat.

The Egyptian leader has emerged a winner all around from the tension and suspicion that surrounded Washington's United Nations intitiative to draw Palestinians into the West Bank autonomy talks, Egyptians believe.

In their eyes, Sadat headed off what he saw as a clear danger to his personal vision of peacemaking with the Israelis. He also did it in such a way, they say, as to build up his deposit of good will with Prime Minister Menachem Begin and his Israeli colleagues.

In addition, he stage-managed it with a varied and ambiguous policy wrapped in such personal warmth that even the Americans whose effort he doomed went away liking him for it, while the Israelis risked alienating a part of U.S. public opinion because of their handling of the Andrew Young affair, the Egyptian observers add.

The entire exercise, aside from its other lessons, demonstrates the extent to which Sadat is determined to follow the guidelines he helped establish in the Camp David accords and the subsequent peace treaty with Israel, despite their imperfections.

Reflecting this, the government-guided Cairo press today trumpeted remarks by "sources" in Washington that the United States is all the more determined to bring about progress in the autonomy talks now that the U.N. tack has been set aside.

American diplomats involved in the failed attempt to win Israeli and Egyptian approval for a new U.N. resolution on the Palestinian question write off Sadat's reluctance as the natural attachment of a man to his own great accomplishment. Having gone so far to achieve the peace treaty, they say, Sadat is unwilling to jeopardize it -- or even inject a sour note into it -- by allowing Americans to confront Israel n w over the Palestinians.

Such a confrontation, Sadat told special U.S. envoy Robert Strauss during their Ismailia meeting Aug. 18, would be "stupid."

His clear stand was unexpected. U.S. diplomats had been told by Prime Minister Mustafa Khalil and the Egyptian minister of state for foreign affairs, Butros Ghali, that Egypt would support any resolution designed to bring Palestinians to their rightful place at the autonomy negotiating table.

Only two nights earlier, Sadat had labeled Arab attempts to get a new Palestinian resolution before the Security Council as "silly acts." His disdain was interpreted then more as an attack on his Arab foes than as opposition to the U.S. attempt at a compromise resolution.

With hindsight, however, his comments look rather like an oblique way to express displeasure at the U.S. initiative without directly criticizing the American benefactors on whom he counts for making the Camp David process work.

Even his strong words to Strauss were spoken in such friendly tones in the balmy breezes of his Ismailia retreat that the U.S. special ambassador -- no mean political backscratcher himself -- said he was impressed by the warmth and sincerity of the Egyptian president.

Again with the advantage of hindsight, it seems clear that Sadat knew his opposition would sink the American initiative, which already was the object of vehement Israeli criticism. With Sadat opposed, Strauss was left with a U.S. proposal that neither principal in the autonomy talks would buy.

The irony was not lost on the Israelis. In Jerusalem the next day, Aug. 19, an aide to Prime Minister Begin was telling journalists that the most important thing to come out of the whole dispute was the spectacle of seeing Egypt and Israel lining up in a common policy opposing Washington.

Sadat is likely to try to capitalize on this when he sees Begin next during his three-day visit to the northern Israeli port of Haifa beginning Sept. 4, Egyptian observers predict.

Plans for the visit indicate that little of substance is on the schedule. Both leaders, however, are said by their aids to be eager to continue building on the personal rapport they reportedly cemented during their talks last month in Alexandria, Egypt.

In the Egyptian view, the sight of Sadat sailing on his yacht into Haifa harbor and exchanging pleasantries once again with Begin serves to underline to his Arab foes the inexorability of Egypt's peaceful intentions.

For Sadat's determination to stick to the Camp David formula, observers here suspect, also contains a desire to prove his Arab detractors wrong. And the American compromise proposal at the United Nations risked shifting the ground rules for autonomy talks in a way that would have accorded some merit to the positions of Saudi Arabia and other Arabs who insist on clearer guarantees for the Palestinians.

This Sadat apparently is unprepared to do at this stage. He said several days ago that the Egyptian people would have to approve in a referendum any Arab overtures to heal the rift caused by his peace treaty with Israel.

The strength of Sadat's conviction also stems in part from an emphasis on deed over word. In his perspective, Egypt has broken out of the venerable Arab tendency to confuse talking with acting and has accomplished more for the Palestinians by acting at Camp David than all the other Arabs ever will by their impassioned declarations of support.

"They demonstrate for the Palestinians before the microphones on the one hand while on the other they warn the United States against the establishment of a Palestinian state." Sadat said last week in a speech marking the end of the Moslem holy month of Ramadan.

That also was what was wrong with the U.S. and Arab attempts at a new Palestinian resolution, he said, adding: "The new resolution. . . is only a general, cloudy formulation. We refuse these general formulations, which accomplish nothing."