U.S. stocks rose on Tuesday as a pair of positive data surprises helped alleviate continued 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 boost from homebuyer tax credits that ended in April.

Consumer confidence was the second positive surprise we had today, suggesting that if we haven't hit the peak of bearishness, we're probably close, said Uri Landesman, president of Platinum Partners in New York.

These two datapoints, combined, are probably preventing what could have been a pretty bad day.

Equities have been pressured in recent weeks by bearish economic data, with a reading of manufacturing activity in the Mid-Atlantic region and U.S. housing starts for July both coming in below expectations during the month of August. 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.

The Dow Jones industrial average <.DJI> was up 51.54 points, or 0.51 percent, at 10,061.27. The Standard & Poor's 500 Index <.SPX> was up 5.16 points, or 0.49 percent, at 1,054.08. The Nasdaq Composite Index <.IXIC> was up 6.20 points, or 0.29 percent, at 2,126.17.

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. Friday's report will be important for giving us direction, but the short-term bias is up.

Limiting the S&P 500's gain was Monsanto Co , the index's top percentage decliner. Monsanto's stock dropped 3.2 percent to $52.70 after the world's biggest seed company forecast full-year earnings below expectations and said it would further reduce its work force.

Though Kaufman said corporate outlooks would dictate market direction in the medium term, he noted that Monsanto is its own story, not part of a trend. It used to be one of my favorite picks, but they've had problems for a long time.

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.15 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, Deere & Co rose nearly 2 percent to $64.21 after a deal to sell its wind power business to electric utility Exelon Corp for about $860 million. Exelon's stock was up 0.4 percent at $40.70.

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)