Two House subcommittees yesterday approved a bill that would ban new loans to and U.S. investment in South Africa unless progress is made toward ending racial segregation there.

In quick action, the Democratic-controlled panels on Africa and on international economic policy and trade swept aside a much milder substitute proposal by Rep. Mark D. Siljander (R-Mich.). Then they approved by voice vote a bill introduced by Rep. William H. Gray III (D-Pa.) and cosponsored by 145 members, including seven Republicans.

The three Republicans present as the subcommittees met together walked out in protest as voting began, leaving only seven Democrats, the minimum number of members needed, for the voice vote.

Speaking for Gray's bill, Rep. Stephen J. Solarz (D-N.Y.) said that "the time has come for the United States to manifest its opposition by deeds, as well as words. The time for sanctions is now."

He attacked Siljander's substitute as "too little and too late" in light of increased violence in South Africa and said that, after after 37 years in power, the South African government is becoming more entrenched in its system of apartheid, or racial segregation.

The substitute bill would have condemned apartheid and established a 15-member U.S. Commission on South Africa to study the situation there and submit a report to Congress after three years. After a short debate, it was voted down along party lines.

The measure approved by the subcommittees may come to a vote of the full Foreign Affairs Committee on Thursday.

The bill would prohibit new U.S. bank loans, directly or through a foreign affiliate, to South Africa or any of its state corporations. The only exception would be for loans or credits for educational, housing or health facilities that are open to all races.

The measure also would ban new U.S. investments in South Africa and the sale of gold Krugerrands, but allow the president to waive both measures if he determines that the Pretoria government has undertaken one or more of eight reforms.

These include elimination of racial laws that bar blacks from living near their work place or in white areas, and of policies calling for removing Africans from white areas. Others involve opening "meaningful negotiations" with blacks for a new political system, freeing political prisoners and achieving an internationally recognized settlement in Namibia.

Another provision would ban exporting U.S. computers for use by the South African government or any state-controlled organization there. An amendment introduced by Rep. Howard L. Berman (D-Calif.) and approved over Republican opposition would require U.S. firms to break existing contracts and stop selling and servicing computers.

The two panels also approved unanimously by voice vote, without the three Republicans, a Senate-passed joint congressional resolution that endorses Secretary of State George P. Shultz's statement March 21 declaring apartheid "repugnant to the people of the United States" and stating that the recent spate of killings "underlines how evil and unacceptable" the system is.

The resolution "requests" that Shultz investigate violence and the March 21-24 killing of blacks in the Eastern Cape area of South Africa, and submit a report to Congress on his findings by June 15.