Stocks clung to tiny gains in afternoon trading on Thursday, retreating from an earlier advance as lower energy prices and an unexpected fall in home sales offset optimism stirred by retailers' better-than-expected monthly sales.

Trading was choppy and likely to remain unpredictable for the day as investors awaited the February non-farm payrolls data on Friday, one of the most anticipated reports to assess the economy's health.

We had a mixed set of data this morning, sort of counterpunching each other and making the market flat, said Stephen Massocca, managing director at Wedbush Morgan in San Francisco.

But more importantly, now we are reaching that part of the day when people want to be balanced, or flat going into tomorrow's critical non-farm payrolls numbers.

The Dow Jones industrial average <.DJI> was up 16.17 points, or 0.16 percent, at 10,412.93. The Standard & Poor's 500 Index <.SPX> was up 0.40 point, or 0.04 percent, at 1,119.19. The Nasdaq Composite Index <.IXIC> was up 1.93 points, or 0.08 percent, at 2,282.61.

The Russell 2000 index of small-cap stocks <.RUT> was on track for another 17-month closing high, a move that suggests it may just be a matter of days before other indexes retest the highs of the rally since March 2009. Fundamentally, small-caps are considered harbingers of an early upturn in the economic cycle since smaller companies are more sensitive than multinationals to domestic business activity.

Friday's employment report is expected to show a loss of 50,000 jobs in February, compared with 20,000 job cuts in January, according to economists polled by Reuters.

Positive brokerage notes helped blue chips head higher, with Boeing Co , Walt Disney , and Coca-Cola Co ranking as the Dow's top three gainers.

Better-than-forecast February retail sales, which were expected to have been hurt by the severe weather across the United States, boosted retailers' shares.

But natural gas futures slid after a government report showed an unexpectedly light inventory drawdown. The NYSE Arca Natural Gas index <.XNG> slipped 1.2 percent, while crude oil futures fell nearly 1 percent to near $80 a barrel.

Boeing shares rose 1.6 percent to $65.48 after UBS upgraded the stock to neutral from sell, citing a strong near-term air traffic outlook and improved forecast for aircraft deliveries and earnings. UBS also raised its price target on Boeing's stock to $68 from $50.

UBS also upgraded Coca-Cola to buy from neutral, sending the stock up 1 percent to $54.46.

Walt Disney rose 2.4 percent to $32.40 after BofA Merrill Lynch upgraded the stock to buy from neutral, and said the top U.S. entertainment company's 2011 earnings could meaningfully outperform market expectations.

Of 28 retailers reporting sales, 76 percent have topped analysts' expectations, with a median surprise of 2.1 percent, according to Thomson Reuters data.

Target Corp added 2.6 percent to $53.02 after it said same-store sales rose 2.4 percent for the month.

In a mixed set of economic indicators, National Association of Realtors said pending home sales fell unexpected in January, while a separate government report showed factory orders rose 1.7 percent for the month.

Earlier in the day, data showed the number of U.S. workers filing new claims for state unemployment benefits fell, but in line with expectations, last week.

(Reporting by Angela Moon; Editing by Jan Paschal)