The U.S. Court of Appeals here yesterday upheld President Carter's authority to deny federal contracts to violators of the administration's wage and price guidelines.

In a 6-to-3 ruling that will be appealed to the Supreme Court, the appellate court for the District of Columbia reversed a lower court decision that Carter had exceeded his constitutional powers in imposing the sanctions.

In contrast to U.S. District Court Judge Barrington Parker, the appeals court found that the guidelines were voluntary rather than mandatory and held that the government's basic procurement statute is sufficiently broad to encompass presidential use of the government's buying powers to fight inflation.

The Court's ruling is a legal victory for the administration and a reprieve for the faltering guidelines program as the administration tries to keep its anti-inflation program from crumbling under the weight of ever-more-costly union wage settlements.

For the time being at least, the ruling restores the only sword the government has been able to hang ove the heads of unions and companies as they negotiate new contracts - the threat of the loss of millions of dollars in government contracts.

It appears to clear the way for sanctions against major rubber companies if, as government sources have indicated, the companies violated the guidelines in recent contract bargaining. United Airlines faces possible sanctions for wage settlements, too, as do several companies for allegedly excessive price increases.

The guidelines seek to limit wage and benefit increases to 7 percent a year and price increases to one-half a percentage point below their average 1976-77 increase.

The sanctions, which have not yet been imposed on any companies, would deny contracts of $5 million or more to companies that violate the standards.

Asserting that the administration was "enormously heartened" by the decision, presidential inflation adviser Alfred E. Kahn told reporters that "it shows the government is not powerless in using its authority" to combat inflation.

"You will have to look at our use of this authority," Kahn added, "and we intend to use it . . . we intend to use this authority where it will help." He said it will be used "firmly."

Other sources said the government will now consider using the sanctions against subcontractors, as well as against those doing business directly with the government, and implied that the $5 million ceiling may be lowered.

The AFL-CIO, which brought the suit against the enforcement sanctions, said it will "immediately appeal" the decision to the Supreme Court. A group of 24 Republican members of Congress who backed the AFL-CIO's suit said they will continue to do so.

In a statement from his home, where he has been convalescing from an injury, AFL-CIO President George Meany said the federation will seek the government's cooperation in expediting the Supreme Court review. The Justice Department declined comment on the request.

There is no guarantee that the Supreme Court will take the case, or, if it does, whether it will hear it before this year's round of contract bargaining is over. The court is expected to recess for the summer within the next weeks.

In a decision closely conforming to Justice Department arguments in the case, Judge J. Skelly Wright, chief judge for the District of Columbia appellate court, said it would be "ironic indeed" for the judiciary to ignore the "legal basis" for a cooperative effort by the Congress and the president to combat inflation.

The country, the court observed, is experiencing a "cruel period of economic inflation."

Taking issue with Judge Parker's contention that the contract sanctions turn the guidelines into a form of mandatory controls that Congress never approved, Wright said the program differs markedly from actual controls.

"Although every denial of a benefit may be viewed in some sense as a sanction, we do not find in the procurement compliance program those elements of coercion and enforceable legal duty that are commonly understood to be part of any legally mandatory requirement," he said.

He likened the contract sanctions to conditional federal grants to state and local governments and to previous government efforts to end on-the-job racial discrimination by federal contractors.

He said the anti-discriminatory executive orders had been rooted in the same 1949 federal procurement law that the administration is now relying on for the anti-inflation sanctions. Judge Wright held that the law's mandate for "economy" and "efficiency" was sufficiently broad to embrace a variety of social and economics goals.

Wright and Judges David L. Bazelon and Edward A. Tamm in separate concurring opinions went out of their way to say they were not giving the president unlimited authority to do anything in the name of fighting inflation.

The decision, said Wright, "does not write a blank check for the president to fill in at his will" but restricts his use of the government's procurement power to the "structure and purposes" of the law.

In a lengthy and strongly worded dissent, Judge George . McKinnon charged that the court's majority had actually opened the door to unintended exercise of presidential power - even to the point of seizing oil companies that sell to the government or imposing "secondary boycotts" against firms that do business with government contractors.

"The recent history of our civilization records so many horribles committed in the name of economy and efficiency that it simply defies common sense and sound judgment to suggest that the 81st Congress [in 1949] contemplated delegating power of that scope to the president," wrote McKinnon.

The president has every right to issue guidelines and urge compliance but not to punish violators without congressional authorization, he said. "He can promote adherence to his suggestions as an act of good citizenship just as he can encourage jogging as a way to good health," said McKinnon.

Also dissenting were Roger Robb and Malcolm Richard Wilkey. Joining Wright, Bazelon and Tamm in the majority were Carl McGowan, Harold Leventhal and Spottswood W. Robinson III.