Inside the closed-door meeting Friday afternoon, members of the House Ways and Means Committee argued over technical changes in their tax-revision legislation.

In a committee office across the hall, one of Ways and Means Chairman Dan Rostenkowski's corporate allies waited for his chance to praise what he thought the legislators would do.

According to the plan, Finn M.W. Caspersen, chairman of the Beneficial Corp., would appear before the television cameras as soon as the committee cut the top corporate tax rate to 35 percent and wrapped up the package. That would happen, Caspersen thought, about 3 p.m. Caspersen would praise Rostenkowski's work in fashioning a tax package that companies could support and say, "By God, he's delivered."

Caspersen never made an appearance. The committee did not complete work until more than 12 hours later, when Caspersen was long gone. And by the time the dust had cleared, Rostenkowski had put the top corporate rate at 36 percent to offset the cost of a last-minute revenue-losing amendment.

It was just one of the many trade-offs that Rostenkowski, a Chicago Democrat, had to make to wrench a bill from his fractious committee during that last, long night.

"I have seen a master politician at work," said Rep. W. Henson Moore (R-La.), who probably will oppose the measure. "He's played the committee like Yehudi Menuhin plays the Stradivarius. It was a virtuoso performance."

From the beginning, Rostenkowski said that politics, not ideology, would govern his effort to overhaul the tax code. Although he said he was committed to the principle of cutting corporate and individual tax rates and curtailing deductions and credits, Rostenkowski was never a pure reformer.

The best tax-reform bill, he and his aides said frequently, is the one that can get 19 votes in the 36-member Ways and Means Committee.

"We have not written perfect law," Rostenkowski said in a statement after the committee completed its work. "Perhaps a faculty of scholars could do a better job. A group of ideologues could have provided greater consistency. But politics is an imperfect process."

The Ways and Means Committee will look at the bill in draft form next week before taking a final vote to send it to the House Rules Committee, which sets procedures for floor consideration of most bills. It is expected to go to the House floor in December.

Ways and Means members have left their imprint all over the legislation. Almost every change in deductions and credits was shaped by one parochial interest or another.

Gravestones, for instance, were spared a tax increase, thanks to Rep. Ed Jenkins (D-Ga.). Rostenkowski's proposal would have cut the depletion allowance for dimension stone, which includes granite and marble. The Jenkins amendment that saved it also left full depletion in place for sulphur and phosphate, which are used as fertilizers.

Jenkins also proposed successful amendments that preserved tax breaks for small construction contractors, banks that invest in bond-financed local projects, rural electric cooperatives and wealthy people who make bequests to their grandchildren.

But he was not the only one who scored victories in preserving tax preferences. Rep. J.J. (Jake) Pickle (D-Tex.), who represents the high-tech city of Austin, persuaded Rostenkowski to go along with not only preserving the tax credit for research and development, but expanding it to include contracts with universities.

Rep. Richard T. Schulze (R-Pa.) gained a more generous depreciation allowance for rental tuxedoes, which are made in Pennsylvania. Rep. Cecil Heftel (D-Hawaii) won a three-year extension of the tax credit for geothermal energy, in abundance in his state, and Rep. Wyche Fowler Jr. (D-Ga.) did the same for the 40 percent credit for solar energy.

Rostenkowski made it clear to panel members that the concessions carried an obligation. During an impassioned speech in a closed-door meeting Thursday evening urging them to crack down on the tax treatment of business meals, Rostenkowski said preserving the three-martini lunch would look bad in a package that would tax unemployment benefits and hurt many other groups.

Then he pointedly reminded members that the committee would next take up transition rules -- the politically important task of setting effective dates that include some projects under the old tax law and leave others in the cold. The implication was that Rostenkowski would remember who voted with him on this issue.

"He was able to put the squeeze on people," said one person who was in the room.

In the 11-page transition package, there are scores of projects and investments that would be allowed to use the more generous provisions of current law, including a Jacksonville, Fla., construction project important to Rules Committee Chairman Claude Pepper (D-Fla.).

In some cases, the compromises secured the support of Ways and Means members for the final package. Preserving the federal income tax deduction for state and local taxes, for example, brought Rep. Raymond J. McGrath (R-N.Y.) into Rostenkowski's camp on every vote. He was the only Republican committee member who stayed after the bill was completed to drink champagne with the staff and the Democrats at 4:30 a.m.

Rep. Richard A. Gephardt (D-Mo.), a supporter of the tax bill, said he plans to generate support for the measure by pointing out to interest groups -- labor, manufacturers, farmers, small business and oil companies -- that concessions were made on their behalf. He said he will make the same point to legislators.

But cooperation can be short-lived. Rep. Charles B. Rangel (D-N.Y.) also spoke strongly in favor of the bill after Rostenkowski agreed to retain state and local tax deductibility. But Rangel almost bottled up the legislation before dawn Saturday with an amendment to exempt all fringe benefits from taxation.

Rostenkowski already had agreed not to tax health-insurance premiums paid by employers on behalf of their workers. Rangel wanted to also exempt group legal services, death benefits and premiums for group-term life insurance. His amendment would have cost $10.5 billion in revenue over five years, violating the "revenue neutrality" crucial to Rostenkowski.

Committee Republicans, openly partisan by that hour of the morning, were insisting on roll-call votes. Democrats who might have voted for taxing fringe benefits on a voice vote would not do so on the record, and the Rangel measure passed.

But Rostenkowski determined that raising the proposed top corporate rate by one percentage point would bring in about $13 billion in revenue, offsetting the revenue loss from the Rangel amendment. Rostenkowski proposed just that, and it passed, 26 to 9