The S&P 500 closed 0.08 percent higher at 2,682.62. Utilities and real estate investment trusts led seven sectors higher, while energy fell 0.3 percent as the greatest decliner.
U.S. crude oil futures settled 33 cents lower at $59.64 a barrel. On Tuesday, crude touched $60 a barrel for the first time in two-and-a-half years.
The Nasdaq composite closed 0.04 percent higher Wednesday as Apple squeezed out a 0.02 percent gain after tumbling Tuesday in its worst day since August. Microsoft, Amazon.com and Facebook closed higher, while shares of Google parent Alphabet fell more than half a percent.
Stocks historically tend to post a "Santa Claus" rally in the last week of December through the first two trading days of January. However, the Dow is the only major U.S. stock index on pace for slight weekly gains, which would be its sixth straight week. If the S&P 500 is able to finish the week higher, the index would close out the year with six straight weeks of higher trade for the first time the since in 1971.
On a monthly basis, the indexes are tracking for gains not seen in decades. The Dow is on pace for its first nine-month winning streak since 1959 and the S&P is on track for its first nine-month winning streak since 1983.
"We've had an amazing run [up] of large-cap stocks. I think we'd all like small cap stocks to follow suit," said Sam Stovall, chief investment strategist of U.S. Equity Strategy at CFRA. "I think it's reflective of investor optimism, but I think investors should become a little cautious."
The S&P 500 is up 19.8 percent this year, while the small-cap Russell 2000 is up about 13.7 percent.
Department store stocks underperformed Wednesday, giving up much of their gains from Tuesday's session. Macy's fell 4.5 percent Wednesday after adding 4.6 percent Tuesday, while Kohl's slipped about 2.8 percent after a nearly 6 percent gain Tuesday. The SPDR Retail ETF (XRT) fell more than 1 percent after rising more than 1 percent to its high for the year Tuesday.
The Mastercard SpendingPulse report showed holiday sales from Nov. 1 to Dec. 24 increased 4.9 percent this year to a record in their largest year-on-year increase since 2011.
U.S. stocks opened higher Wednesday, helped by gains in commodity prices.
Copper hit a more than three-and-a-half year high Wednesday after China reported a 19 percent year-on-year increase in imports of the metal in November, according to Reuters.
Earlier, copper hit a high of $3.302 a pound on the New York Mercantile exchange, its highest since Feb. 2014.
"Obviously commodities futures have been beaten down all year. It's kind of encouraging to see this late-in-the-year resurgence," said John Caruso, senior market strategist at RJO Futures.
"I still think stocks are probably going to grind higher in the next week or two," Caruso said, adding he expects some profit-taking in January.
However, over the first 11 months of 2017, China's copper imports are down more than 10 percent from the same period in 2016, the newswire said. A private survey of Chinese businesses called the China Beige Book also said late Tuesday New York time that a slower pace of growth in hiring and manufacturing orders, among other concerning factors, point to a likely slowdown in the world's second-largest economy next year.
The Shanghai composite closed 0.9 percent lower, while the Nikkei 225 gained 0.08 percent.
In Europe, London's FTSE 100 climbed to an all-time high. Major European markets were closed Tuesday and Monday, and U.S. markets were closed Monday for the Christmas holiday.
U.S. stocks closed lower Tuesday, dragged down by a decline in Apple shares.
Stocks have rallied in the last few weeks on anticipation of stimulative tax reform. President Donald Trump on Friday signed a bill that cuts the corporate tax rate to 21 percent from 35 percent. The president was able to sign the bill after Congress approved another bill to keep the federal government funded through Jan. 19.
In U.S. economic reports, the Conference Board's consumer confidence index fell to 122.1 in December from 128.6 in November. Though the index shows that Americans are still upbeat, the fall in sentiment did raise eyebrows on Wall Street.
"The only thing that matters to me today is the drop in expectations in consumer confidence," said FBN Securities Chief Market Strategist Jeremy Klein. That's "one of the biggest drops we've seen in the past couple years."
Klein said the slip in confidence was notable given the debate and passage of sweeping tax changes over the past month and may reflect popular sentiment toward the bill.
In other data news, signed contracts to buy existing homes rose 0.8 percent in November from the same month last year, the first annual gain since June of this year, according to a seasonally adjusted monthly index of pending home sales from the National Association of Realtors. However, the index was up just 0.2 percent from October.
Treasury yields fell Wednesday, with the 2-year yield near 1.88 percent after hitting a nine-year high of 1.927 percent overnight. The 10-year yield traded near 2.41 percent.
The euro briefly topped $1.19 to hit its highest against the U.S. dollar in more than three weeks.
Gold futures for February delivery settled up 0.28 percent at $1,291.40 an ounce.