U.S. stocks were little changed on Tuesday as positive news from the corporate earnings season offset data pointing to weak consumer demand.

Earnings dominated the news, with Johnson & Johnson's profit and revenue beating analysts' forecasts. J&J, a Dow component whose products range from Band-Aids to complex biotech drugs, rose 0.3 percent to $57.90.

Goldman Sachs reported a near doubling of trading revenue, although its stock was up just 0.07 percent at $149.54 after a gain of more than 5 percent on Monday.

Stocks were also bolstered by comments from the chief executive of railroad company CSX Corp , who said on Tuesday that the worst of the recession seems to be over.

The company, which reported better-than-expected results on Monday after the closing bell, saw its shares rise 6.3 percent to $34.58. The Dow Jones Transportation Average <.DJT> gained 1.3 percent.

There have been very few negative pre-announcements so far, which leads us to believe that we will see a predominance of reporting in line with or above expectations, said Tim Ghriskey, chief investment officer of Solaris Asset Management in Bedford Hills, New York.

The Dow Jones industrial average <.DJI> was up 2.49 points, or 0.03 percent, at 8,334.17. The Standard & Poor's 500 Index <.SPX> rose 1.96 points, or 0.22 percent, to 903.01. The Nasdaq Composite Index <.IXIC> was up 2.79 points, or 0.16 percent, at 1,796.04.

The energy sector <.GSPE> advanced 0.6 percent, boosted by U.S. crude futures rising 36 cents, or 0.6 percent, to $60.05 a barrel.

Helping to limit gains was Dell Corp's forecast late Monday of lower gross margins in the quarter as demand has shifted toward cheaper computers such as netbooks.

Dell shares fell 7.2 percent to $12.08, weighing down the Nasdaq and the S&P 500's information technology index<.GSPT>.

Even though June total retail sales rose 0.6 percent, which was more than forecast, a big part of that gain was due to rising gasoline prices. Excluding autos and gas sales, retail sales registered a fourth consecutive monthly decline.

A rebound in sales is considered vital for the U.S. economy to bounce back from recession, as consumer spending accounts for roughly two-thirds of the country's economic activity.

(Editing by Jan Paschal)