President Carter yesterday signed into law his long-sought energy bill that will raise fuel prices, then flew to the Midwest and reassured farmers the government will continue to support their prices.

Both actions by the president yesterday - the signing of legislation that will gradually deregulate the price of natural gas and his announced intention to continue to keep cropland out of production - will put upward pressure on consumer prices.

But the president nonetheless reasserted the controlling inflation is "my top domestic commitment," promising to submit to Congress in January a "very tight, very stringent, very difficult budget" with a deficit of less than $30 billion.

At a nationally televised "regional" news conference here, Carter said it is "highly likely that we will have [farm] set-asides" next year, and he promised a decision no later than next week.

The situation facing the president is at what level to continue the set-aside program for feed grains such as corn. Currently, farmers are required to remove 10 percent of their land from production to qualify for price supports and other government benefits. If they voluntarily remove another 10 percent of their land from production, they receive direct government payments.

The effect is to restrict supply and boost prices, although White House aides here insisted that Carter's decision will not have a major impact on inflation.

On other topics during the news conference, which was dominated by questions on domestic issues, Carter:

Said he has no plans to call for a "substantial change" in the legislation that will increase Social Security taxes in January. Some eonomists have proposed a rollback in the higher taxes as an anti-inflation measure, but the president said that if he did advocate such a course the reduced revenues would have to be made up from general tax funds.

Disagreed with political analysts who have suggested that the replacement of a number of liberal Democratic senators by Republicans in last Tuesday's elections will make it more difficult to win approval of a new strategic arms limitation treaty (SALT) with the Soviet Union."I don't anticipate partisanship will pay a part in the passage or ratification of the SALT agreement," he said.

Hinted that he will veto meat import legislation that would restrict his authority to increase imports to force down prices at home. Carter authorized higher beef imports earlier this year, angering farmers throughout the country.

Defended his commitment to continue to increase defense spending while ordering cuts in domestic social programs. "There is no way I can cut down the ability of our nation to defend itself," he said. "Our security obviously comes first."

Predicted that Missouri's rejection Tuesday of a state "right to work" law (banning closed union shops) will discourage similar attempts to enact such laws in other states.

Following the news conference, Carter addressed the national convention of the Future Farmers of America here. Speaking without a text, his speech was part a nostalgic recollection of his youth on a Georgia farm, part exhortation to his audience to always seek excellence and part a revealing glimpse into his views of the presidency.

"As a young man and as president, I have learned some things about leadership," Carter said. "One is that the fear of failure is one of the greatest obstacles to progress. How timid we are when we challenge some obstacle or engage in some contest or set a high goal for ourselves. How timid we are that we might fail in the effort and perhaps be the subject of ridicule or criticism or scorn."

"It is always a mistake to try for universal approbation, universal approval, because if you fear making anyone mad, then you ultimately probe for the lowest common denominator of human achievement," he added.

The president gave litany of his predecessors and their frustrations, and spoke in a somewhat defensive tone about his own role as an American president in the 1970s.

"I have found it much more difficult to be a leader in a time of calm than in a time of crisis," he said. "Leaders are very popular in a time of crisis because it is easy to arouse support for the interests of those who are concerned with the crisis itself. But to take action to prevent a future crisis that can't be easily detected nor proven is a very difficult task indeed."

Before flying here, the president signed the national energy legislation at a White House ceremony. In its final form, the measure was far from what Carter originally proposed almost 19 months ago when he called on the American people to undertake "the moral equivalent of war" to curb energey consumption.

"We have acquitted ourselves well as a nation," Carter said with obvious satisfaction as he signed the bill.

"Many people," he added, "gave up hope that our Congress was able to deal with so complicated . . . and politically sacrificial an issue."

The bill's chief feature is the gradual deregulation of the price of natural gas. It also contains watered-down provisions to encourage industry to convert to coal as a fuel and to encourage consumers to insulate their homes and purchase more fuel-efficient cars.

At the news conference, Carter said he does not know what changes in energy policy he will seek from Congress next year.

"But I have not given up on my original proposal that there should be a constraint on the excessive consumption of oil and therefore the excessive importation of oil," he said. "How we will go about it, I don't yet know."

This was a reference to one of Carter's original proposals to impose a federal tax on domestic oil production, thereby by raising prices to encourage conservation. The proposal ran into heavy opposition in Congress and was eventually dropped from the legislation.

During the news conference, the president defended his decision to sign the $18.7 billion tax-cut measure earlier this week although it fell far short of his goals. "On balance, it was acceptable. It was necessary," he said.

He also predicted that labor union members will support the administration's anti-inflation program despite the criticism of that program by AFLCIO President George Meany.

"I think most labor members . . . feel that it is much better for them to control inflation than it is to let it run rampant, even if they were to get some small temporary increases in wages . . ."

Asked about Tuesday's election results, Carter said the gains made in Congress by the Republican Party will not affect the kind of legislation he proposes next year.

"I think there was a general expression around the country of approval for the Democratic Party and its policies," he said. "I don't look at it as a referendum of whether I have done a good job or not."

Carter also downplayed the importance of his own campaigning (16 of the 28 Democratic Senate and Gubernatorial candidates he campaigned for lost), saying he doubted he had much impact.

"I would say when they lost, I had a substantial impact. When they won, they did it on their own merit," the president said with a grin.