Stocks rose for a third straight day on Wednesday as weakness in the dollar lifted commodity and industrial shares while data underscored optimism that the economy was improving.

Shares of industrial companies that benefit from a weaker dollar gained, including General Electric Co , up 5.9 percent at $16.94. The dollar's decline also boosted commodities prices, which in turn lifted shares of natural resource companies.

The dollar continues to get pounded. That translates into higher commodity stocks, and industrials continue to be a beneficiary, of the dollar's weakness, said Michael James, senior trader at regional investment bank Wedbush Morgan in Los Angeles.

U.S. industrial output advanced for a second consecutive month in August, while higher gasoline costs pushed up consumer prices, although economists said the risk of inflation remained low.

That added to optimism that the economy was getting better, a day after Federal Reserve Chairman Ben Bernanke said the recession was very likely over.

Financial companies also were top gainers, with the S&P financial index <.GSPF> up 2.5 percent.

The Dow Jones industrial average <.DJI> was up 98.55 points, or 1.02 percent, at 9,781.96. The Standard & Poor's 500 Index <.SPX> was up 14.08 points, or 1.34 percent, at 1,066.71. The Nasdaq Composite Index <.IXIC> was up 26.92 points, or 1.28 percent, at 2,129.56.

The S&P hit a high for the year shortly after the open, and is now up about 56 percent from the March 9 low. The dollar, meanwhile, dropped to near one-year lows against the euro and a basket of currencies.

Adding to the positive tone was the latest sign that merger and acquisition activity was picking up. Adobe Systems Inc said it plans to pay $1.8 billion for Omniture Inc, whose software analyzes Web traffic. Adobe, the maker of Photoshop and Acrobat software, is looking to turn around declining sales.

Adobe was down 6.6 percent at $33.28, while Omniture advanced 26.7 percent to $21.95.

HMO shares advanced after Democrat Senator Max Baucus said his health-care overhaul can pass the Senate. A health-care stock index <.HMO> was up 1.7 percent.

Shares of Exxon Mobil Corp gained 1.1 percent to $70.24 as oil futures rose 2 percent. Oil at one point rose above $72 a barrel on Wednesday.

Gold prices hit 18-month highs. Freeport-McMoran Copper & Gold Inc , up 1.4 percent to $72.35.

(Reporting by Caroline Valetkevitch; Editing by Kenneth Barry)