Stocks were little changed on Friday with the S&P 500 locked in a tight trading range and as the dollar gained, but encouraging data limited the downside.

After breaking above a key technical level around 1,228, the S&P hit resistance at 1,235, which represents the two-year intraday high reached earlier in the week. The index climbed as high as 1,236.93 before falling back.

In the latest economic data, consumer sentiment rose more than expected in early December, while import prices in November climbed at their fastest pace in a year, data showed. Also, the U.S. trade deficit narrowed much more than expected in October.

Recent better-than-forecast economic reports have boosted optimism that the economy is slowly but surely gaining ground, and some analysts see the market to rallying into the end of the year after a short-term consolidation.

Robert Tipp, chief investment strategist for Prudential Fixed Income in Newark, New Jersey, said the market is likely to be stuck in a range as sentiment vacillates between optimism and pessimism.

Basically the market, after being excessive pessimistic, is having to re-evaluate following the announcement of QE2, better-than-expected data, and the stimulus from the extension of the tax cuts. So the market had a big swing in sentiment, said Tipp.

The Dow Jones industrial average <.DJI> inched up 6.66 points, or 0.06 percent, at 11,376.72. The Standard & Poor's 500 Index <.SPX> added 1.90 points, or 0.15 percent, to 1,234.90. The Nasdaq Composite Index <.IXIC> rose 4.52 points, or 0.17 percent, to 2,621.19.

A gain in the dollar also weighed on equities as the dollar index <.DXY> rose 0.1 percent. Stocks and the greenback have moved in opposite directions of late.

Shares of Netflix Inc jumped after Standard & Poor's said the movie rental company along with F5 Networks Inc and Newfield Exploration Co will replace Office Depot Inc , New York Times Co and Eastman Kodak Co in the S&P 500. Netflix was up 2.2 percent at $195.31.

(Additional reporting by Ryan Vlastelica; editing by Jeffrey Benkoe)