Optimism about corporate earnings, bolstered by JPMorgan Chase & Co, lifted the stock market slightly on Friday, offsetting lukewarm economic data and putting the S&P 500 on track for a seventh straight week of gains.

The S&P Midcap 400 index surpassed its all-time intraday record, rising 0.4 percent to hit 928.05. The index includes companies ranging from $750 million to $3.3 billion in size.

On balance, with supporting prices and in spite of mixed economic data, there is expectation of a strong earnings season, said Jim Awad, managing director at Zephyr Management in New York.

The Dow Jones industrial average <.DJI> rose 34.63 points, or 0.30 percent, to 11,766.53. The Standard & Poor's 500 Index <.SPX> added 5.28 points, or 0.41 percent, to 1,289.04. The Nasdaq Composite Index <.IXIC> increased 9.57 points, or 0.35 percent, to 2,744.86.

After JPMorgan reported its stronger-than-expected fourth-quarter earnings, the bank's shares added 2.4 percent to $45.53, while the KBW banking index <.BKX> rose 2 percent.

Strength in banking stocks helped offset U.S. government data that showed December retail sales slightly weaker than expected.

In other economic news, higher gasoline prices helped push December consumer prices up at the 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.

The average gasoline price of $3.09 a gallon is the highest since $3.15 on October 13, 2008, according to the Energy Department's weekly survey of service stations.

U.S. oil prices have soared more than 62 percent since early 2009, contributing to an eight-month climb in the S&P energy index <.GSPE>, which 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.

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

Even though there are concerns about Intel's strategic positions, their numbers were good, JPMorgan's numbers were good and expectations are that you have a strong earnings season in the fourth quarter, Awad said.

Financial shares 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.

However, capping S&P's gains, materials stocks <.GSPM> declined 0.2 percent, spurred by a selloff in gold. U.S. gold futures <.XAU> fell 1.7 percent to a one-week low on Friday after China's central bank raised lenders' reserve requirements.

(Reporting by Alina Selyukh; Editing by Kenneth Barry)