During his seven years as secretary of Housing and Urban Development, Samuel R. Pierce Jr. has developed a profile so low that he has often been labeled "Silent Sam."

Yesterday, Pierce had his moment in the spotlight when he was hailed by President Reagan during a White House ceremony as "one of the unsung heroes of our administration."

The president's praise came as he signed the first major housing bill enacted during the seven years of his administration, a measure the president once denounced as a "budget-buster" and threatened to veto.

But in the presence of Pierce, the only member of Reagan's initial Cabinet still on the job, the president hailed the legislation as "a rational, cost-effective bill that's fiscally responsible."

Reagan credited "the four Republican horsemen" -- Sens. Jake Garn (Utah), Pete V. Domenici (N.M.), William L. Armstrong (Colo.) and Phil Gramm (Tex.) -- with helping to transform the bill into one he could accept. But he saved his most lavish praise for Pierce, who has been sharply criticized by housing advocates for tolerating the administration's deep cuts in HUD programs.

"His loyalty and hard work, his good sense and commitment can be seen in this bill," the president said. "Few others could have brought such divergent forces together."

Outside the Roosevelt Room, where the signing occurred, some of the guests were less charitable about the bill. Sen. Alan Cranston (D-Calif.), chairman of the Senate subcommittee on housing and urban affairs, called it "a meager beginning." Helen Sause, president of the National Association of Housing and Redevelopment Officials, said in a statement, "It took seven years to obtain enactment and a presidential signature on . . . a very modest piece of legislation."

The bill, the first major piece of housing legislation to reach the White House since 1980, provides $15 billion for housing and community development in the current fical year and $15.3 billion in the year beginning Oct. 1. One of the key provisions makes permanent a program of housing vouchers, which the Reagan administration first proposed in 1982.

Congress had funded the program previously as a demonstration project, reflecting many Democrats' belief that the vouchers, which allow low-income families to select their housing, may be costlier than traditional housing programs for the poor.