Stocks edged higher on Friday after the government reported the economy shrunk at a slower-than-expected pace in the second quarter, which investors took as a sign the recession is easing.

Trading was volatile after the government report also showed a drop in consumer spending, a crucial driver of corporate profits and economic activity.

Even so, investors snapped up shares of big manufacturers such as 3M Co , which was up 1 percent, and big-cap technology companies, including Apple Inc, which gained 1.2 percent.

Overall, the numbers weren't as bad as what the headlines showed, and once you start going through the numbers, we're headed in the right direction, said Alan Lancz, president of Alan B. Lancz & Associates Inc, an investment advisory firm in Toledo, Ohio.

The worrisome factor is the consumer and what a big part of our economy the consumer is, and we don't see any kind of rebound there.

The Dow Jones industrial average <.DJI> climbed 42.47 points, or 0.46 percent, to 9,196.93. The Standard & Poor's 500 Index <.SPX> gained 3.48 points, or 0.35 percent, to 990.23. The Nasdaq Composite Index <.IXIC> rose 9.76 points, or 0.49 percent, to 1,994.06.

A positive close on Friday would give the benchmark S&P 500 its fifth straight monthly advance.

Travelers Cos Inc , one of the largest U.S. home, auto and commercial insurers, was among the standouts following positive broker comments, a day after the company raised its forecast for the year. Its stock jumped 2.8 percent to $43.11.

Shares of companies seen as better able to withstand an uncertain economy also advanced, with Merck & Co Inc up 1.4 percent at $30.34.

On the downside, Walt Disney Co shed 2.4 percent to $25.60. The media and entertainment powerhouse reported a 26 percent slide in quarterly earnings late Thursday as the recession continued to hurt advertising and consumer spending.

Even though Disney beat expectations by a hair, its shares were the Dow's top drag. JPMorgan downgraded the stock to underweight from neutral on Friday.

The GDP report showed consumer spending, which accounts for about two-thirds of U.S. economic activity, fell at a 1.2 percent rate in the second quarter after rising 0.6 percent in the previous quarter.

With the contraction in the second quarter, U.S. GDP has fallen for four straight quarters for the first time since government records started in 1947.

(Reporting by Ellis Mnyandu; additional reporting by Leah Schnurr; editing by Jeffrey Benkoe)