There is a chance -- even at this late date -- for President Reagan to sang substantial from a session of Congress that has been more of a shambles than the triumph to which his second-term landslide might normally have entitled him.

The "something" is no cheap, symbolic victory but a major step toward the overhaul of the federal tax code -- the goal Reagan put at the top of his wish list back in January, when the election mandate was fresh and shiny.

Since then, the president has been forced to sound retreat on defense spending, to accept a budget that fell far short of dealing with the deficit problem and to see much of his social- issue agenda rejected.

This month he is scrambling to find compromises that will spare his policy on South Africa and on foreign trade from being run over by a rebellious Republican Senate.

The only thing that can rescue this year from going into the record books as the year the "Reagan Revolution" ran aground is a breakthrough on the big tax bill. And given the widespread belief that Reagan has failed to ignite the voters' passion for what he likes to call "America's tax plan," a victory on this measure would seem like a real long shot.

But it's a long shot that can come through.

The chief reason for making that rash judgment is a bit of political perversity: This is one issue where the divided party control of Congress works to the president's advantage.

The best political operatives in the administration are convinced that they can get a serious, substantive tax bill through the House before Halloween.

They believe this because Chairman Dan Rostenkowski (D-Ill.) of the House Ways and Means Committee has set that as his timetable, and Rostenkowski is in a position to deliver. By force of personality, more than by intellectual dominance, the veteran Chicago Democrat has begun to build into his fractious committee a sense of the discipline he learned in the Daley machine.

Those who attended the committee's "retreat" last weekend in Virginia were impressed by the group spirit Rostenkowski has built and by the absence of doctrinaire or demagogic debate on the tax bill.

Slowly and patiently, Rostenkowski has managed to cultivate the notion among his colleagues that this is the opportunity for Ways and Means to demonstrate that the cynics are wrong. This is their chance to show that they are not so hogtied by the campaign contributions they have received, not so subservient to the lobbyists that surround them, that they cannot legislate in the national interest.

Rostenkowski's motives are complex but powerful, and he is ready to ride his committee hard in closed-door markup sessions and to make the compromises there that will prevent the bill from being picked apart on the House floor. The substantive issues are serious, but after the "retreat," they do not seem insoluble, as long as Rostenkowski can maintain the current camaraderie within his committee.

If the Democratic House passes a strong tax bill by a big bipartisan margin in October, as now seems possible, the political heat will shift to the Republican Senate.

No one in the administration is kidding himself about the Senate's wish to duck, defer or defeat the whole Reagan-inspired scheme. The Senate cares more about the deficit, trade, farm supports, foreign policy and a dozen other things than it does about tax reform. It has its own ideas on rewriting the tax code, which are far removed from Reagan's or Rostenkowski's and tend to favor some form of consumption or business transfer tax.

Left to its own devices, the Senate might well postpone tax reform right past the 1986 election or hold it hostage for Reagan's acceptance of a tax increase.

But if Rostenkowski delivers on schedule, Reagan will have an opportunity to capture the momentum of his House victory and tell the Republican Senate: I want you to deal with this tax issue in November as responsibly and promptly as the House has done in October.

Despite their claims that the calendar is running out on Senate action this year, it might be hard for Majority Leader Bob Dole (R-Kan.) and Senate Finance Committee Chairman Bob Packwood (R-Ore.) to refuse such a request from a president about to leave these shores for a summit meeting with the leader of the Soviet Union. What the Senate puts in the bill is probably less important to the administration than its moving a measure to passage before adjournment.

The final tax terms will be written in the House-Senate conference committee in any case. But if both chambers have passed tax reform in 1985, there is little risk it will die in conference in 1986.

Instead, the odds would be good for Reagan's receiving a delayed Christmas present soon after Congress returns in January -- and before it receives his new budget and resumes its normal pattern of kicking Reagan around.