A hospital cost-control bill squeaked through the House Ways and Means health subcommittee yesterday, 7 to 6, but only after subcommittee Democrats substantially weakened President Carter's initial proposal by allowing hospitals to try out a voluntary cost-control program before any mandatory federal ceiling is imposed.

The amendment establishing a voluntary program - backed by standby mandatory controls which the president could use if the voluntary approach doesn't keep costs down - was sponsored by subcommittee Chairman Dan Rostenkowski (D-III). Several members said openly that the bill couldn't have passed in its stronger, original form, and an administration official said, "We preferred our own version but we're happy the bill wasn't killed altogether."

All the votes for the revised version came from Democrats. Two of them, William R. Cotter (D-Conn.) and Harold Ford (D-Tenn.), questioned whether the measure can get through the full Ways and Means Committee even as revised, and indicated they voted for it only out of respect for Rostenkowski.

Carter has made hospital cost control a key request in his legislative program and has strongly insisted on mandatory controls as the only way to hold down rocketing hospital costs throughout the nation.

Secretary of Health, Education and Welfare Joseph A. Califano Jr. said last week that "a voluntary program won't work." However, some observers believe the president may end up being forced to swallow voluntary controls, with a standby mandatory program, or get nothing at all.

At present, hospital costs are growing at about 16 percent a year. Under the Rostenkowski bill, hospitals - under a voluntary program worked out by the American Hospital Association, the American Medical Association and other groups - would have to reduce the rate of growth to about 14 percent after one year and to 12 percent the following year and keep it at 12 percent or less thereafter.

If they failed to meet that goal, then the bill would trigger a mandatory federal program that would limit growth of hospital revenues to about 12.3 percent in its first year and push the growth rate down to 10 percent after five years - substantially lower than the voluntary program. If the mandatory program were to start in 1979, some time after the fiscal year begins, it would cut hospital costs by more than $700 million during the remainder of that fiscal year and $9 billion a year by 1983. The mandatory program would be enforced by financial penalties on those that don't comply.

The administration proposal, by contrast, provided for an immediate mandatory program that would clamp a lid of about 9 percent on hospital cost growth by 1980 - lower still than the subcommittee standy mandotory provisions.

The American medical and hospital assosciations oppose the bill even in its weakend from because of dislike of madatory controls. Yesterday, AFLCIO spokesman Bob McGlotten said, "We're opposing the bill."

McGotten said the unions are against the bill because it does'nt contain a provision in the standby mandatory control section requiring increased labor costs for hospital blue-collar workers to be ignored in determining whether hospital costs have reached the ceilings in the bill. The bill does allow hospital to ignore such costs if they choose, but the unions want this made mandatory to make sure that requests for wage inceases won't be resisted on grounds they would put the hospital over the cost-control barrier.

Although approved by the Rostenkowski subcommittee, the bull must now fight its way through a jurisdictional jungle, and its long-term prospects are uncertain. In the House, two committees have jurisdiction - Ways and Means, where the prospects are unclear; and Interstate and Foreign Commerce, where a subcommittee has already approved a version based on the administration's mandatory approach without any voluntary program.

In the Senate, the HUman Resources Committee has already approved a mandatory bill close to the administration proposal, but the Senate Finance Committee, which also has jurisdiction, is working on an entirely different bill.