President Reagan took a shot Wednesday at Michael Dukakis for refusing to release his medical records, but said he was "just trying to be funny" when he called the Democratic presidential candidate an "invalid."

Reagan caused an uproar at an impromptu White House news conference to announce his veto of the defense bill when he was asked if Dukakis should release his medical records.The question came a day after The Washington Times published a report alluding to "rumors" that Dukakis has undergone treatment for depression. The Dukakis campaign denied the rumors.

"I'm not going to pick on an invalid," Reagan said as he was leaving the briefing room. Asked what Reagan meant, White House spokesman Marlin Fitzwater said: "I don't know." The presidential crack drew exclamations of surprise from those assembled in the room.

Less than an hour later, speaking to reporters before the start of a meeting with media executives on the situation in Nicaragua, Reagan, apprised of the political reverberations of his remark about Dukakis, all but apologized.

"I was just trying to be funny," he said, "and it didn't work."

Saying he was speaking from the personal experience of having had his own health subjected to intense scrutiny, he said, "I do believe the medical history of a president is something the people have a right to know."

Dukakis has consistently refused to release his records, offering only a July 1987 letter from his physician declaring Dukakis has been treated only for "minor, self-limited ailments and regular health reviews."

Dr. Gerald Plotkin also declared Dukakis in "excellent physical health and condition" with "no major ailments during your entire life, and there is nothing in your past or current medical history that should interfere with the ability to serve as president."

Jesse Jackson, in Detroit, called Reagan's remark "unfortunate and ugly language beneath the dignity of an American president," and Vice President George Bush, touring a Westinghouse defense plant in Annapolis, Md., said he was unaware of Reagan's remark but said, "I'll talk to the president about it."