A jump in materials shares helped U.S. stocks eke out a second straight day of gains Thursday, though disappointing forecasts from retailers and anxiety ahead of Friday's jobs report limited the advance.

The S&P 500 materials index rose 2.8 percent, leading the day's gains, as declines in the U.S. dollar lifted copper and other metals prices.

The dollar index fell for a fourth day on the latest batch of soft U.S. data, which dampened expectations for U.S. interest rate hikes this year. A weaker dollar benefits big U.S. companies that depend on overseas sales.

Data showed non-farm productivity fell in the fourth quarter at its fastest pace in more than a year, while new orders for U.S. factory goods also fell in December by the most in a year.

The weaker data came ahead of Friday's key monthly jobs report from the U.S. government, which is expected to show 190,000 non-farm jobs added in January.

Adam Sarhan, chief executive of Sarhan Capital in New York, said the market is trying to bounce from "deeply oversold" levels, but is struggling because of continued weakness in earnings and economic data.

"We're now seeing a lot of weaker-than-expected economic data coming out," he said. "The bullish catalyst just isn't there to justify further rate hikes."

The Dow Jones industrial average rose 79.92 points, or 0.49 percent, to end at 16,416.58, the S&P 500 gained 2.92 points, or 0.15 percent, to 1,915.45 and the Nasdaq Composite added 5.32 points, or 0.12 percent, to 4,509.56.

Consumer-related shares were among the day's biggest losers in the S&P 500 after retailers Ralph Lauren and Kohl's warned of a tough year ahead. Ralph Lauren sank 22.2 percent to $89.95 while Kohl's fell 18.8 percent to $41.52, the two biggest percentage decliners in the S&P 500.

The consumer discretionary index was down 0.6 percent, while S&P staples was down 0.9 percent.

Stocks have had a rough start to 2016, hurt by tepid U.S. growth, falling oil prices and concern that the world faces a China-led slowdown.

UBS cut its year-end target and trimmed its earnings estimate for the S&P 500 on the weaker U.S. growth prospects.

Fourth-quarter S&P 500 earnings are expected to have fallen 4.2 percent from a year earlier, according to Thomson Reuters data.

GoPro fell 8.7 percent to $9.78 after the camera maker forecast current-quarter revenue below analysts' estimates.

After the bell, shares of LinkedIn dropped 24 percent following the networking site operator's results and forecast.

About 9.5 billion shares changed hands on U.S. exchanges, compared with the 9.4 billion daily average for the past 20 trading days, according to Thomson Reuters data.

Advancing issues outnumbered declining ones on the NYSE by 1,949 to 1,087, for a 1.79-to-1 ratio on the upside; on the Nasdaq, 1,659 issues rose and 1,123 fell for a 1.48-to-1 ratio favoring advancers.

The S&P 500 posted 11 new 52-week highs and 11 new lows; the Nasdaq recorded 14 new highs and 83 new lows.

(Additional reporting by Tanya Agrawal; Editing by Don Sebastian and Nick Zieminski)