U.S. stocks eked out gains on Wednesday despite another rise in oil prices as investors bet the latest data signaled the economy could absorb expected higher energy costs.

Wall Street seesawed as oil fluctuated throughout the day. Brent crude hit a 2 1/2-year high above $117 a barrel in the late morning but later slipped. Brent settled up 93 cents at $116.35.

The initial shock waves (from a spike in oil prices) are gone... (and) we are realizing that the world economy is doing OK, that our economy is OK. It's balancing each other out, said Joseph Benanti, managing director at Rosenblatt Securities in New York.

The day's rally was broad with eight out of 10 S&P 500 sectors ending higher. Sectors that are sensitive to energy gained, including industrials <.GSPI> up 0.4 percent and materials <.GSPS> up 0.2 percent. S&P infotechnology sector <.GSPT> rose 0.7 percent.

But trading volume was at 7.69 billion shares on the New York Stock Exchange, NYSE Amex and Nasdaq, lower than last year's daily average of 8.47 billion. Volume has recently been solid on days when the market falls and lighter on up days.

Economic data was positive, with the Federal Reserve's Beige Book suggesting economic activity picked up in 2011 and a private survey pointing to strong private-sector hiring.

Stocks have taken their cue from oil since the start of turmoil in the Middle East and northern Africa in January. The fear was that rising oil prices could derail the recovery. For a graph of equities' correlation to oil, see http://r.reuters.com/mut38r

The Dow Jones industrial average <.DJI> was up 8.78 points, or 0.07 percent, at 12,066.80. The Standard & Poor's 500 Index <.SPX> was up 2.11 points, or 0.16 percent, at 1,308.44. The Nasdaq Composite Index <.IXIC> was up 10.66 points, or 0.39 percent, at 2,748.07.

Private employers added more jobs than expected last month, the ADP Employer Services report said, before the closely watched and broader U.S. government report on non-farm payrolls due on Friday.

A broker upgrade of the semiconductor sector helped the Nasdaq. The Philadelphia semiconductor index <.SOX> rose 1.4 percent.

Texas Instruments Inc gained 3.3 percent to $36.14 after JPMorgan upgraded the semiconductor sector, including Texas Instruments, saying an inventory correction was nearing an end and demand appeared to be improving.

Apple shares boosted the Nasdaq after Chief Executive Steve Jobs surprised investors by personally presenting the new iPad at an event in San Francisco. The stock rose 0.8 percent at $352.12.

Shares in Yahoo Inc rose 3.3 percent to $16.63. The company is in advanced talks to leave its Japanese joint venture and free up as much as $8 billion to compete with Google Inc and Facebook.

(Reporting by Angela Moon, Editing by Kenneth Barry)