NEW YORK - Stocks ended an erratic session yesterday with a slim gain as rising commodities prices offset disappointment over a drop in new-home sales.

Gains in commodities drove the shares of energy and materials-producing companies higher, lending support to the overall stock market. Gold, oil, and other commodities rose.

The dollar ended a four-day winning streak as the economic data reinforced investors' belief that the recovery from the recession will be slow.

The Commerce Department said sales of new homes plunged 11.3 percent in November.

The housing disappointment followed news that personal spending and income rose in November. But economists say growth remains too weak to sustain a strong economic recovery.

Stock trading has been choppy recently as investors' optimism about the recovery surged and then ebbed. On Monday, the market rallied as corporate mergers raised investors' confidence. Yesterday's trading showed how uncertain investors really are.

Volume was light as investors closed up shop ahead of the Christmas holiday. Those still trading are not making any major moves as the year winds to a close.

"People are not doing any new trading," said Benny Lorenzo, chief executive officer of New York-based Kaufman Bros. "They are just holding on to their gains for the year."

The Dow Jones industrial average rose 1.51, to 10,466.44. The Standard & Poor's 500 index rose 2.57, to 1,120.59, while the Nasdaq index gained 16.97, to 2,269.64.

The ICE Futures U.S. dollar index, which measures the dollar against other currencies, tumbled 0.5 percent. The decline in the dollar makes commodities cheaper for foreign buyers. Oil surged 3 percent, rising $2.27 to close at $76.67 a barrel on the New York Mercantile Exchange.

Tim Courtney, chief investment officer at Burns Advisory Group, said Wall Street's mild reaction to the day's economic data might be a reflection of the fact that there were few appealing alternatives for investors right now.

Reflecting investors' indecisiveness, bond prices were little changed yesterday after three days of declines. The yield on the benchmark 10-year Treasury note held steady at 3.76 percent.

Three stocks rose for every one that fell on the New York Stock Exchange, where volume came to an extremely slow 785.9 million shares, down from 955.5 million on Tuesday.