Stocks were near flat on Wednesday as unrest in the Middle East and North Africa kept investors cautious, but materials shares gained.

The Federal Reserve's rejection of a dividend plan by Bank of America weighed on bank stocks.

Brent crude was trading around $116 a barrel as further unrest in Yemen added to risks of oil supply disruptions in the region.

Analysts said oil prices could stay high in the near term, improving the outlook for energy companies, but at the same time causing concern about the dampening effect of high energy costs for consumers.

The area at this point looks volatile so oil prices are going to remain elevated and drift higher, said Fred Dickson, chief market strategist at D.A. Davidson & Co. in Lake Oswego, Oregon.

The big energy stocks are participating in the move with crude, but the surprise is refiner stocks have benefited, which means producers and refiners are passing through price increases fairly quickly, he said.

Shares of Exxon Mobil , which were down 0.3 percent at $82.29 on Wednesday, have gained 13 percent since the start of the year.

The Dow Jones industrial average <.DJI> was up 23.84 points, or 0.20 percent, at 12,042.47. The Standard & Poor's 500 Index <.SPX> was down 1.14 points, or 0.09 percent, at 1,292.63. The Nasdaq Composite Index <.IXIC> was up 1.37 points, or 0.05 percent, at 2,685.24.

Refiner Valero Energy shot up 2.6 percent to $28.83 at midday. For the year, Valero's stock is up 25 percent.

Bank of America Corp shares slid 2.5 percent to $13.53.

In data that suggested the housing market's problems were continuing, U.S. new home sales fell in February to a record low and prices were the lowest since December 2003. For details, see STORY:

Among the day's gainers were Freeport-McMoRan Copper & Gold , up 3.9 percent at $54.33 as metals prices rose. Gold rose to near an all-time high.

Speaking at a Reuters summit in New York, Freeport-McMoRan Chief Executive Richard Adkerson said the company has the balance sheet to handle a large acquisition.

The S&P index of materials stocks <.GSPM> was up 0.8 percent.

(Reporting by Caroline Valetkevitch; Additional reporting by Angela Moon; Editing by Jan Paschal)