U.S. stocks erased losses in a late flurry of buying to end little changed on Tuesday as overall optimism about earnings offset disappointing results from blue chips 3M and Johnson & Johnson.

About 70 percent of S&P companies so far have beaten estimates, but worries about inflation cutting into profits have caused investors to jump on shares of companies that only produce spectacular results.

Stocks were lower for most of Tuesday's trading. Shares of 3M Co fell 2 percent to $88.50 after results barely topped estimates and the manufacturer warned rising raw material costs would pressure its bottom line.

Today the market is simply a little tired and overbought, said Bruce Bittles, chief investment strategist at Robert W. Baird & Co in Nashville.

But selling has been ineffective, including today; the benefit of the doubt has to go to the bullish case.

The Dow Jones industrial average <.DJI> finished down 3.33 points, or 0.03 percent, at 11,977.19. The Standard & Poor's 500 Index <.SPX> was up 0.34 point, or 0.03 percent, at 1,291.18. The Nasdaq Composite Index <.IXIC> was up 1.70 points, or 0.06 percent, at 2,719.25.

The S&P 500 index bounced off support at 1,280 in a sign of the market's resilience despite some disappointing earnings.

Investors will focus on U.S. President Barack Obama's State of the Union speech to Congress on Tuesday at 9 p.m. ET. His remarks could have an impact on energy, infrastructure and other market sectors.

Trading volume was 7.97 billion shares on the New York Stock Exchange, the American Stock Exchange and Nasdaq, down from last year's estimated daily average of 8.47 billion shares.

Not all blue chips disappointed investors. Verizon Communications Inc shares rose 1.6 percent to $35.79 after company said it added far more wireless subscribers than expected in the quarter.

Travelers Companies Inc rose 1.1 percent to $56.23 after it posted a higher-than-expected quarterly profit.

The rising cost of commodities ranging from oil to food is emerging as the main threat to an earnings recovery that has helped push U.S. stocks to their highest levels since the 2008 financial crisis.

Major U.S. companies across a spectrum of industries, from blue-chip manufacturing companies 3M Co and DuPont Co, to tissues and diapers maker Kimberly-Clark Corp and fashion accessories house Coach cited rising costs as a risk to growth this year.

Stocks have rallied such that you need to have really blowout numbers for shares to continue gaining, said Michael Yoshikami, president and chief investment strategist at YCMNET Advisors in Walnut Creek, California.

I think we'll see a trend of strong earnings but stocks that dip afterwards.

With reports in from 22 percent of S&P 500 companies, earnings for the fourth quarter are now expected to have increased 34.9 percent from a year earlier, according to Thomson Reuters data. That forecast was up from 31.9 percent at January 1.

Healthcare company J&J said U.S. sales of consumer products fell sharply and forecast 2011 earnings below expectations, sending its shares down 1.8 percent to $61.08.

After the bell, Yahoo Inc reported quarterly net revenue that fell 4 percent and forecast a further slide this quarter, sending its shares down 3 percent to $15.54 in extended trade.

The latest economic data showed U.S. consumer confidence rose in January to its highest level in eight months, but single-family home prices fell for a fifth straight month in November.

Advancing stocks outnumbered declining ones on the NYSE by 1,603 to 1,379, while on the Nasdaq, decliners beat advancers 1,430 to 1,212.

(Additional reporting by Rodrigo Campos; Editing by Kenneth Barry)