Stocks rose in choppy trading on Tuesday, closing out a weak month for equities as a pair of positive data surprises on the consumer and housing fronts helped ease investor anxiety over the economy's strength.

U.S. consumer confidence rose more than expected in August, lifted by a mild improvement in the short-term outlook, though a separate report showed business activity in the U.S. Midwest registered a slowdown in August, growing a bit less than economists expected.

Earlier, the Standard & Poor's/Case Shiller home price indexes showed prices of U.S. single-family homes rose slightly more than expected in June, reflecting the lingering lift from homebuyer tax credits that ended in April.

The fact that two of the weakest areas of the overall economy (the consumer and the housing sector) can show resilience, even for a short time, suggests that other areas will also be moving on into growth, said Bruce McCain, chief investment strategist at Key Private Bank in Cleveland, Ohio.

Equities have been pressured in recent weeks by bearish economic data and anemic trading volume, which has exacerbated moves. In the month of August, a reading of manufacturing activity in the Mid-Atlantic region and U.S. housing starts for July both missed expectations.

For the month, the Dow is down 4 percent, while the S&P is off 4.5 percent and the Nasdaq is down 5.8 percent.

This Friday, investors will be paying close attention to the August non-farm payroll number, which is expected to confirm that the economy shed jobs during the month, keeping investors reluctant to hold positions.

The Dow Jones industrial average was up 31.97 points, or 0.32 percent, at 10,041.70. The Standard & Poor's 500 Index was up 2.47 points, or 0.24 percent, at 1,051.39. The Nasdaq Composite Index was up 0.97 of a point, or 0.05 percent, at 2,120.94.

Before rebounding, the S&P 500 neared 1,040 in early trading, a key support level that was successfully defended twice last week.

Bouncing off the 1,040 level shows that this is a market driven by technicals, said Wayne Kaufman, chief market analyst at the New York-based John Thomas Financial.

The Dow and S&P trimmed gains after Jason Furman, an economic adviser to President Barack Obama, told a meeting on Tuesday there was a concern that even a temporary extension of the Bush-era tax cuts for the wealthy would be a foot in the door to permanent extension.

Limiting the S&P 500's gain was Monsanto Co, the index's top percentage decliner, falling 6.1 percent to $52.52 after it forecast full-year earnings below expectations and said it would further reduce its work force.

The Nasdaq's advance was curbed by Research in Motion Ltd. The Canadian's company's U.S.-listed shares lost 5.3 percent to $43.18 after Sanford C. Bernstein cut its price target on the stock, citing a threat to the contribution to earnings from the BlackBerry maker's corporate business.

On the upside, Pfizer Inc rose 1.1 percent to $16.03 after researchers said an experimental drug the Dow component made with Bristol-Myers Squibb Co reduced the risk of stroke by more than half compared with aspirin, with no significant rise in major bleeding.

Saks Inc surged 22.6 percent to $8.08 after a news report suggested that a group of private equity firms might soon bid for the New York-based luxury department store operator.

Later on Tuesday, the Federal Reserve is scheduled to release the minutes from its policy meeting on August 10, when it endorsed a more dovish monetary posture, citing a willingness to reinvest in monetary accommodation. Last week, Fed Chairman Ben Bernanke said in a speech the recovery had weakened more than expected.

(Editing by Jan Paschal)