THE STATE OF MARYLAND complained that the federal gasoline-allocation system is unfair to it. Maryland wanted a federal court to order a formula that will be perfectly fair to everybody. It was a nice try. But it ought to be clear by this time that a formula perfectly fair to everybody is a shining ideal that no court or legislature will ever acheive.Judge Herbert Murray expressed sympathy, but correctly threw out the suit.

The allocation system that seems fair to Maryland will be attacked as a travesty in Texas or California. The formula that seems adequate to suburban commuters will bring the farmers and bussiness angrily into court. Compromises acceptable to the tourist industry will be anathema to the trucking industry. Sooner or later, if not in the Maryland case, a court will tell the Department of Energy that its allocation rules are much too loose and informal A judge will require new rules, detained and codified, with full provision for hearings, appeals and rehearings. Even if they are fairer when they are drawn up, they will be obsolete within six weeks as the continent's demands for gasoline shifts in a hundred ways that nobody can forsee.

But the pattern of maldistribution within Virginia raises even more troubling questions. Notoriously, the state's shortage has been concentrated in the Northern Virginia suburbs. There has been hardly any shortage at all around Richmond. Gasoline allocations promise to turn into one of the more valuable kinds of political patronage. Under Gov. John N Dalton, Virginia seems to have followed the squeaking-wheel principle in handing out gasoline. The state's distribution formula also seems to include a factor for proximity to the state capital.

Legal challenges to the present allocation system are inevitable. But they are going to make the system worse by making it more complicated and more rigid. One solution is, of course, to keep fiddling around with it and waiting for the recession to end the shortage by eroding demand.

The simpler and better solution is to abolish price controls on gasoline now, with a stiff tax to make the distributors share the proceeds with the public. Whenever that proposal comes up, Congress wrings its hands and drums its heels and cries that gasoline taxes aren't popular. How true. But it's hard to think that many people really prefer prpetual misallocation, incrasingly susceptible to political manipulation, with the lines vanishing and reappearing unpredictably at the filling stations.