The Ford administration, as part of a campaign to attract foreign investment in the United States, entered into secret agreements with several Middle East governments to protect the confidentiality of those investments, according to report yesterday by the General Accounting Office.

The secrecy practice is being continued by the Carter administration, according to the GAO.

The report, made public by a House government affairs subcommittee, called the agreements "unique and . . . not consistent with out treatment of other nations." The subcommittee is investigating the U.S. investments by members of the Organization of Petroleum Exporting Countries (OPEC).

Subcommittee chairman benjamin S.Rosenthal (D-N.Y.) said "the secrecy surrounding OPEC investment and the refusal by Federal agencies to provide detailed and meaningful information on the nature and extent of such investment compounds public concern and inhibits congressional and public consideration of this vital issue."

In an undated internal treasury Department memorandum obtained by the Washington Post, Deputy Assistant Secretary for International Monetary Affairs F. Lisle Widman defended the secrecy agreement with respect to the Saudi Arabians.

"Release of data on the assets of the Saudi government could have . . . dangerous implications," Widman wrote to his superior, Assistant Secretary C. Fred Bergsten. "We could well lose the cooperation of the Saudis as a moderating force both on financial and energy questions . . . They have also been the major stabilizing force within OPEC against countries which have pressed for pricing oil in currencies other than the dollar."

At yesterday's hearings, economist and author Paul Erdman, warned that the hidden OPEC investment in the U.S. represents "a present and growing danger to U.S. banks and the U.S. economy."

Outlining several methods used by OPEC nations to conceal investments in the U.S. - usually involving the Euromarkets and complex arrangements with foreign banks - Erdman estimated actual OPEC investment in the U.S. at about $85- $90 billion, nearly twice what the GAO report estimated.

Erdman also challenged a GAO assertion that the present OPEC investment poses little short-term threat to our financial system. GAO official J. Dexter Peach testified that although the long-term affects of constant withdrawal by the OPEC nations of their investment could hurt, it was unlikely that a rapid disposal of OPEC assets would "pose a significant danger," because the world financial system would stabilize any such action.

Peach said, for example, that if an Arab country withdrew all of its money from Chase Manhattan Bank and deposited it in a German bank, the German bank would merely turn around and re-deposit that same money with Chase, and the only loss would be the additional interest Chase would have to pay to the German bank for the money.

"That is just how the world works," Erdman said. "If the Arabs sell their dollar holdings, they will cause a run on the dollar, and no German bank, or any bank, will offer that money back to Chase."

Erdman said the OPEC nations are likely to invest at least half of their growing surpluses "in the U.S., directly or indirectly, with the majority of such investment being directed at deposits with U.S. banks."

He said that because of this growing investment, which he said would likely involve as much as $200 billion over the next six years, "the danger to our financial system will likely increase at a geometric rate."

While he acknnowledged that it is unlikely that responsible bankers in the Middle East would do anything to jeaopardize the world financial system because of their own stake in its continued good health, he warned "what about Kaddafi? What about the Ayatollah Khomeini? What about the PLO? . . . Suppose a new wave of left-wing radicalism sweeps through the region and sweeps out the current responbible regimes?"

Erdman whose novel "The Crash of 79" describes a fictionalized financial collapse of the world due to unrests in an OPEC country that leads to that country rapidly withdrawing its investments from major banks - said "it is very peculiar how things are catching up with the book." He wrote the book in late 1975.