President Reagan, smiling broadly but walking stiffly, left the hospital to return to the White House yesterday, 12 days after the nation's heart skipped a beat as Americans saw Reagan struck by a bullet that pierced his left lung.

Reagan said he felt "great" as he walked out of George Washington University Hospital at 10:44 a.m. with Nancy Reagan holding his right arm and his younger daughter, Patti Davis, holding his left.

"What are you going to do when you get home?" a reporter asked.

"Sit down," the president replied.

Doctors released Reagan after an X-ray taken yesterday morning showed the remaining trace of the bullet wound in his lung looking much improved. "We are quite comfortable letting him go home today," Dr. Dennis O'Leary, a hospital spokewman, said.

Although doctors have been impressed by the rapidity of the 70-year-old Reagan's recovery, they say that he will not be able to work in the Oval Office for at least a week and should not travel for several weeks.

The president had no visitors scheduled for the weekend and is expected to work about two hours daily in his study next to his bedroom for the next several days.

After a five-minute drive through the rain, Reagan was greeted by cheers and applause from about 250 people gathered under umbrellas on the White House South Lawn.

The president wore a bright red cardigan and white polo shirt. Except for the evident care with which he walked, he looked well as he stood and waved his left arm to the damp crowd. A banner reading, "Welcome Home, Mr. President" was hung on the White House facade behind him.

Vice President and Barbara Bush greeted the Reagans before the president went inside, where he was met by White House counselor Edwin Messe III and his wife, Attorney General William Rench Smith and his family and White House chief of staff James A. Baker III and his 3-1/2-year-old daughter, Mary Bonner Baker. Office of Management and Budget Director David A. Stockman, Health and Human Services Secretary Richard Schweiker and Commerce Secretary Malcolm Baldrige were in the crowd on the lawn.

"This looks like a nice place," the president remarked as he stepped into the White House. He went over and kissed Mary Bonner Baker, who was in her father's arms.

When doctors told Reagan at 7:45 a.m. that he could leave the hospital, the president replied: "I'd already decided that," according to White House deputy chief of staff Michael K. Deaver, who spent the morning at the hospital.

The president ate his last hospital breakfast and remarked, "Food is starting to taste better. Since that macaroni and cheese it's all been uphill." Reagan was referring to his request for macaroni and cheese for dinner Thursday, a choice he later regretted having made.

At 10:30 a.m., Reagan left his third-floor room for the last time. The first person waiting to greet him was Sarah Brady, the wife of press secretary James S. Brady, who was the most seriously wounded of the four men hit by bullets in the assassination attempt March 30 outside the Washington Hilton Hotel.

They embraced.

The president has not yet spoken to Brady since the shooting, but deputy press secretary Larry Speakes said there are plans for Reagan to telephone Brady over the weekend.

In accord with hospital rules, Reagan was wheeled to the elevator, but he said, "I walked in here. I'm going to walk out," and left his wheel-chair behind.

In the hospital lobby about 40 people were gathered for his departure and he thanked them for their care. "I know I arrived here rather unexpectedly and I apologize for the disruption," Reagan told them as they applauded.

The White House press office later issued a statement from the president thanking everyone involved in his treatment and saying the experience gave him new respect for the men and women who practice medicine.

The most difficult moment of the trip from the hospital to the White House for Reagan appeared to be getting into his limousine. Deaver told reporters that the pearl gray limousine was chosen because it was easier to get into than the more often used black one, but the maneuver clearly was uncomfortable for Reagan.

Deaver stressed that the president is going to readjust to his schedule gradually. Asked whether the president might speak on radio or television this week, Deaver said: "I don't think it would be this week. We're not going to rush anything.

In the White House, Nancy Reagan has prepared a third-floor solarium for Reagan's use while he recuperates. The glass-enclosed room has a new beige rug, has been freshly painted beige and been decorated with tulips.

White House physician Daniel Ruge will check Reagan every day and the surgeon who removed the .22-caliber bullet from Reagan's lung. Dr. Benjamin Arron, will drop by from time to time, Speakes said. No special medical treatment is necessary for the remainder of Reagan's recovery, doctors said.

D.C. police officer Thomas K. Delahanty also left th Washington Hospital Center for home yesterday. "I feel good . . . I'm ready to go," he said.

Reagan left the hospital without paying his bill. Speakes said the bill is expected to arrive at the White House early in the week.