Corporate earnings drove stocks mostly higher Thursday. Major indexes shifted between small gains and losses ahead of the scheduled Good Friday closing.

The gains kept the indexes ahead for the week, though they remained down for the month.

The S&P 500 index rose 2.54 points, or 0.14 percent, to close at 1,864.85. Seven of the 10 industry sectors increased, led by energy stocks. The Nasdaq added 9.29 points, or 0.23 percent, to close at 4,095.52.

The Dow, however, slipped 16.31 points, or 0.1 percent, to 16,408.54.

Thursday morning, the market appeared set for its fourth consecutive positive opening this week, but things immediately turned negative as investors sold shares in Google and IBM, which reported disappointing earnings late Wednesday. Earnings from toy maker Mattel and insurer UnitedHealth also dragged down the market.

But by midmorning, the market started to push up as traders cheered upbeat results from General Electric and PepsiCo.

"We were expecting this earnings season to be pretty volatile, and it's proven to be true so far, in that we're seeing some differences in the results," said Paul Mangus, head of equity research and strategy for Wells Fargo Private Bank.

Harsh winter weather in much of the country weighed on everything from auto and home sales to hiring, and investors are eager to hear what CEOs have to say about business prospects going forward.

Thursday's trading reflected buying and selling on earnings news rather than a broader market theme taking hold, Mangus said.

Among companies whose earnings pleasantly surprised investors was GE, which described the economic situation as "positive" and said its industrial division was doing well. PepsiCo reported a higher profit after slashing costs and selling more snacks.

GE gained 44 cents, or 1.7 percent, to close at $26.56. PepsiCo added 78 cents, or about 1 percent, to finish at $85.55.

IBM struggled with a decline in its hardware business in the latest quarter. Its stock slid $6.39, or 3.3 percent, to $190.01.

UnitedHealth Group said its income slid 8 percent in the first quarter as fees and funding cuts from the health-care overhaul dented its performance. It fell $2.41, or 3.1 percent, to $75.78.

Bond prices fell, pushing up the yield on the 10-year Treasury note to 2.72 percent, from 2.63 percent late Wednesday.