With the help of Nancy Reagan and a one-candle cake, President Reagan yesterday turned a mini-news conference into a nationally televised birthday party and a supposedly adversary press corps into smiling props for the early matinee performance.

The carefully staged drama cast Reagan as the good-guy president and members of the press, particularly the front-row television correspondents, as all part of his happy little White House family. Newspaper reporters out of range of the cameras in the White House briefing room became a Greek chorus whose only role was to laugh or applaud an exchange of one-liners between the Reagans and the television correspondents.

The president had the best lines. While the First Lady presented the small cake to her husband and cut a larger, hazelnut cake for reporters, Reagan deftly sliced away at television correspondents whom he recently accused of making too much of his off-the-cuff statements favoring elimination of corporate taxes.

When Mrs. Reagan tried to shush ABC's Sam Donaldson by handing him a piece of cake, Donaldson demurred, saying, "But you understand we won't sell out for a piece of cake . . . . "

"Oh, you've sold out for less than that," replied the president with a broad smile.

"If I had a comeback, I would not dare, not dare say it," Donaldson said.

A little later Donaldson tried again, with a question he accurately labeled "a softball," asking whether Reagan had any observations to make on his birthday.

Reagan fielded this one with the statistical flair for which he has sometimes been noted, observing that "it's just the 31st anniversary of my 39th birthday," which would make him 70.

Actually, Reagan will be 72 on Sunday. The "31st anniversary" line was a repeat of the one he used two years ago, when he really was 70.

The line was born during the 1980 presidential campaign, when Reagan's strategists sought to defuse concern that he was too old by conspicuously celebrating his birthday with a series of parties before his opponents could get around to observing it.

Once Reagan commits a one-liner to memory, it is sure to surface again. In 1980 he said over and over again, as he did yesterday, that he had enjoyed every one of his birthdays, "and I think it's fine when you consider the alternative."

During that campaign Reagan was given seven birthday cakes. He fell into the last one of them, in South Carolina, prompting the press corps to score the competition as "Reagan 6, Cakes 1."

Yesterday, however, it was the television networks that fell into it. As is customary, they were informed about the coming news conference by David R. Gergen, the White House communications director, about 45 minutes before the event. All of the networks decided to air it live.

"We put the president on the air because of the news potential, not for cutting a birthday cake," said Robert McFarland, the NBC bureau chief in Washington. "We were surprised. We were not happy."

Gergen, however, was very happy.

"It was wonderful," he said. "He Reagan thoroughly enjoyed it. I think the press enjoyed it. People have questioned whether there are tense relations between the president and the press corps. I think this helped take the edge off."

Not all of the press agreed.

Several reporters were conspicuously silent during an off-key rendition of "Happy Birthday" started by the staff and joined in by some members of the press corps. Others complained that they had been "used" by the White House. But the prevalent view, particularly of the television correspondents, seemed to be that the news conference was worth the birthday celebration.

"It's the same kind of hokey stuff they've been doing since I've covered the guy," said CBS' Bill Plante "It was ready-made for television, just like in the campaign. You have to take it with a tiny grain of salt, but I was willing to let them have their fun."

White House officials credited Nancy Reagan, whose political sense is valued in administration councils, for the idea of the birthday cake presentation. Once begun, the party developed a life of its own, with Mrs. Reagan passing out cake to the multitude, and each network abandoning live coverage at different times.

ABC bowed out first, with anchorman Frank Reynolds commenting, "This could go on forever." CBS left next, and NBC stayed until nearly the end. McFarland said this extended coverage cost NBC "a lot of money" in commercial time and was based on a technical decision enabling the network to rejoin regular coverage "cleanly in all time zones."

The NBC bureau chief said that the birthday party maneuver would be "remembered," but the White House has usually found the networks willing to cover most events in which the president takes questions from their correspondents.

The only hitch yesterday, from the White House point of view, was in the opening act, which almost didn't get on stage. Reagan was giving a long answer while deputy press secretary Larry Speakes and Nancy Reagan, holding the cake on which a single candle was rapidly burn- ing down, stood waiting in the wings.

Though Speakes joked that the president was "filibustering" to prevent his wife from presenting the cake, Reagan would have done well to end his serious answer sooner. By the time his wife finally interrupted him for the presentation of the cake, Reagan had said the overall budget number was "freed," when he meant frozen, and said he had cut increased defense budget projections of President Carter in half, when he meant his own projections.

But when the cake-cutting started, Reagan was in firm control, reinforcing his nice-guy image before a late-morning television audience, with reporters providing the supporting cast.