The moral of this story might be that if at first you don't succeed, try another shade of Green.

It all began Tuesday night when the White House released its guest list for the dinner President Carter gave Israeli Prime Minister Menachem Begin. From Capitol Hill were two U.S. senators and eight members of the House -- all Democrats except Rep. S. William Green of New York.

On its guest list of 140 names, however, the White House identified Green as representing Pennsylvania.

"I was a little puzzled to discover that I was the only Republican from Congress there," said Green, also a little surprised to find himself associated with the state of Pennsylvania when the guest list appeared in the newspaper yesterday. "But I was delighted to be there and see the prime minister again."

Green, who represents the 18th Congressional District in New York, came to Congress in 1978 after defeating Bella Abzug in a special election for the House seat vacated by now-New York Mayor Edward Koch.

By yesterday, in response to inquiries, an aide to Green said he had no idea why his boss was linked with Pennsylvania.

"Maybe the White House thought it was inviting a Pennsylvania Democrat," said the aide.

In fact, there used to be a Pennsylvania Democrat in the House named Bill (William J.) Green, but he ran for the U.S. Senate in 1976 and was defeated by Henry H. Heinz III. That Bill Green is now mayor of Philadelphia.

Coincidentally, while New York's Bill Green was being welcomed to the White House by Jimmy Carter on Tuesday, Philadelphia's Bill Green was endorsing another Democrat for president: Sen. Edward M. Kennedy.

The White House expressed surprise that anyone might think there had been a mixup in Greens. "Just a typo," said a White House aide. "Given the fact that Mayor Green just endorsed our opponent, I'm sure he wouldn't have come last night."

As for Rep. Green, he's already got a candidate for president. He is the only Republican convention delegate from New York committed to Rep.John Anderson (R-Ill.)