Stronger-than-expected earnings from JPMorgan Chase & Co lifted the stock market slightly on Friday, offsetting weak economic data and putting the S&P 500 on track for its seventh straight week of gains.

The S&P Midcap 400 index, recently bolstered by optimism about corporate earnings, surpassed its all-time intraday record, rising 0.2 percent to hit 926.78. The index includes companies ranging from $750 million to $3.3 billion in size.

Shares of JPMorgan added 2.6 to $45.61 after its earnings report, while the KBW banking index <.BKX> rose 1.2 percent.

We're optimistic that the earnings season starting is actually going to be pretty positive, said Thomas Nyheim, vice president and portfolio manager at Christiana Bank & Trust Co in Greenville, Delaware.

Earnings should offset not-so-good economic numbers that are coming out, Nyheim said.

U.S. government data showed December retail sales slightly weaker than expected.

Also, higher gasoline prices pushed overall December consumer prices up at their fastest pace in a year and a half, which also weighed on consumer sentiment in early January, according to a Reuters/University of Michigan survey.

Driving prices at the pump, U.S. oil prices have soared more than 62 percent since early 2009. The S&P energy index <.GSPE> has been rising for eight months and is close to its highest since October 2008.

Another week of gains for the benchmark S&P 500 would make it the longest stretch since April-May 2007.

The Dow Jones industrial average <.DJI> gained 19.07 points, or 0.16 percent, to 11,750.97. The Standard & Poor's 500 Index <.SPX> added 3.32 points, or 0.26 percent, to 1,287.08. The Nasdaq Composite Index <.IXIC> rose 6.99 points, or 0.26 percent, to 2,742.28.

Dow component Intel Corp fell 0.9 percent to $21.11, a day after it posted a better-than-expected quarterly profit and forecast strong revenue for the coming quarter.

Financials have been the biggest market driver in recent weeks. Since the start of December, the KBW banking index surged almost 21 percent, while the S&P gained almost 9 percent.

On Friday, financials also received a boost from S&P Ratings Services when the agency released an optimistic outlook for 2011, forecasting further stabilization.

In a sign of sputtering state and local finances around the country, most of the 137 companies hitting new 52-week lows on the New York Stock Exchange were closed-end municipal bond funds. Shares of BlackRock Inc , the world's biggest money manager, were also at 52-week lows, down 0.4 percent on the day to $6.76.

(Additional reporting by Chuck Mikolajczak; Editing by Kenneth Barry)