NEW YORK — Stocks closed higher Wednesday on Wall Street, nudging the S&P 500 to its first gain in four days, as investors weighed a mixed set of reports on the economy.

The S&P 500 inched up 0.1% after shedding most of its gains from earlier in the day. The benchmark index remains on track for a weekly loss. Gains by financial, communication services, energy and other sectors were kept in check by declines elsewhere, including technology companies, which helped pulled the Nasdaq slightly lower.

Investors continued to bid up shares in smaller company stocks, driving the Russell 2000 small-cap index to its second straight all-time high.

An hour before trading began on Wall Street, the government released an avalanche of data on the economy that showed some optimistic signs and several disappointing ones. But the market seemed to largely shrug off the reports.

“The economic data is being largely discounted,” said J.J. Kinahan, chief strategist with TD Ameritrade. “It seems to be that the rollout of the vaccine for the coronavirus is starting to go pretty well, so that’s what’s giving people a lot of hope. At the end of the day, that still remains the top story.”

The S&P 500 rose 2.75 points to 3,690.01. The benchmark index set a record high Thursday and is up 14.2% so far this year. The Dow Jones Industrial Average added 114.32 points, or 0.4%, to 30,129.83. The Nasdaq composite fell 36.80 points, or 0.3%, to 12,771.11. The tech-heavy index has notched new highs 54 times this year as Big Tech companies have led the market higher.

The Russell 2000 index climbed above the 2,000-point mark for the first time. It gained 17.22 points, or 0.9%, to 2,007.10. The index has risen 10.3% this month.

Overnight, Wall Street had seemed to be heading for a rockier day of trading. U.S. stock futures initially dropped after President Donald Trump said that he may not sign the $900 billion rescue for the economy that Congress just approved. But they eventually drifted upward as investors looked past the unexpected pushback.