The Dow Jones industrial average made another run at 13,000 but couldn't quite get there.
Stocks recovered from an early loss Thursday and pushed the Dow within four points of the milestone. Investors were encouraged by more good news on U.S. jobs, but gains were limited by poor results from retailers such as Safeway and Kohl's.
The Dow finished up 46.02 points at 12,984.69. The Standard & Poor's 500 index gained 5.80 points to close at 1,363.46. The Nasdaq composite index climbed 23.81 points to 2,956.98.
The Dow pierced 13,000 three times Tuesday but could not hold the milestone. The average hasn't closed above 13,000 since May 19, 2008, four months before the financial crisis.
Investors were encouraged Thursday after the government reported that the number of people seeking unemployment benefits last week was unchanged. The four-week average was the lowest in four years.
High unemployment has been a problem for retailers, who have been forced to slash prices even though they are paying more to make and ship their goods. The burden showed in Thursday's earnings reports.
Kohl's, the department store chain, sank 6 percent after weak holiday sales caused it to miss Wall Street estimates for revenue and earnings. Grocery store chain Safeway Inc. plunged more than 7 percent after reporting a 6 percent drop in profit.
Part of the problem is the rising cost of gas, which could hurt the economic recovery. The price of gas is rising as tensions mount over Iran's nuclear program. A gallon of regular sells for $3.61 on average, the highest on record this time of year.
The price of oil jumped again Thursday, to $107.83, a nine-month high and up $1.52 for the day. Besides Iran, analysts blamed the falling U.S. dollar. When the dollar falls in value, it takes more dollars for foreign buyers to pay for the same barrel of oil.
The euro jumped to a two-month high against the dollar, $1.337, up almost a penny from Wednesday, after business confidence surged in Germany.
Dillard's, another department store chain, and the discount chain Target also missed analysts' estimates. Earlier this week, Walmart fell short on earnings and revenue after aggressive discounts for the holidays cut into profit margin.
For the most part, U.S. stocks have been rising since Thanksgiving, as the most potent fears of last summer -- that the country would enter another recession and that the European debt crisis would damage the U.S. economy -- have dissipated.
The market has yet to settle into a definitive trend, however. In the 36 completed trading days so far this year, the Dow has risen on 21 and fallen on 15.
"On Tuesday the world is ending, on Wednesday the opposite happens, after two or three weeks we're right where we started because not much happened," said Bill Hampel, chief economist of the Credit Union National Association.
Of the S&P 500's 10 industry groups, nine finished the day higher. Financial stocks led the charge forward, partly because of a calm day for news about Greek debt talks. U.S. bank stocks were pummeled last year as investors worried about exposure to European debt, but some of those concerns have eased.