The Kennedy Center Opera House turned itself into Nostalgia Theater last night to honor five great American artists for their lifetime achievements.

There was singing and dancing throughout the evening: Bass Donald Gramm of the Metropolitan sang a Mozart aria in honor of Leontyne Price; Natasha Makarova and Anthony Dowell danced an exquisite "Manon" pas de deux for President and Mrs. Carter; James Galway played "Danny Boy" on his gold flute for James Cagney; and a new ballet centering on a Forth of July scene in Texas was danced to choreography devised by Agnes de Mille signaling her acceptance of the honor.

Beverly Sills was a mistress of ceremonies to dream of: "We are now going to have a major scene change backstage," she told the audience about 10:30, after the show had been running nearly three hours. "I have offered to tell jokes or repeat some of the behind-the-scenes gossip, but they tell me we are going to have some music that recalls the careers of our honored guests."

The audience, many of whom had been to the White House to visit with the five guests of honor, heard a sound track taken from President Carter's tributes to Lynn Fontanne, Agnes de Mille, Leontyne Price, James Cagney and Leonard Bernstein. President and Mrs. Carter were greeted with prolonged, affectionate applause from the audience and heard Sills note that the Carter's attendance at 28 events in the Kennedy Center during their Washington years set a record for presidential interest in the arts.

The tributes were as varied as their recipients; Jamie Bernstein flew in from Hollywood to sing a song, "Thank You," written out of love for her father. Jason Robards, reminding the audience that yesterday was Fontanne's 93rd birthday, spoke of the length and variety of her great career, throughout which she and Alfred Lunt were inseparable. Zubin Mehta paid high tribute to Price, whom he first heard 25 years ago in Vienna; and Lauren Bacall reviewed the glories of the Bernstein career. Pat O'Brien, speaking without notes or prompt cards, talked about his 35 years of friendship with Cagney, and Kitty Carlisle Hart brought up vivid memories of de Mille. Film clips made it easy to remember the greatness of the five who, at the end of the evening, came on stage together, causing one of the loudest and most heartfelt ovations in Kennedy Center history.

CBS television will show the entire program on Dec. 27.