(AP) -- Wall Street closed out a wobbly day of trading Friday with the major stock indexes notching their second straight weekly gain.
The S&P 500 and Nasdaq eked out tiny gains, good enough to nudge each to an all-time high for the fourth time this week. The Dow Jones Industrial Average ended with a slight loss.
Gains in the technology, real estate and utilities sectors outweighed losses in energy and industrial stocks, and in consumer-centric companies.
Trading was mostly subdued and cautious following China's report Thursday of a surge in cases of a new virus that raised fresh concerns about global economic growth.
"We were flat for most of the day," said Quincy Krosby, chief market strategist at Prudential Financial. "But you're also seeing that there is concern. Gold is up, money has come into the bond market and the yields have come down."
The mixed finish for the indexes likely indicates some traders elected to sell and pocket some profits ahead of the long holiday weekend to get ahead of potential negative headlines about the virus, analysts said. U.S. markets will be closed Monday for the President's Day holiday.
The S&P 500 index rose 6.22 points, or 0.2%, to 3,380.16. The Nasdaq composite gained 19.21 points, or 0.2%, to 9,731.18. Both indexes had been down most of the afternoon.
The Dow dropped 25.23 points, or 0.1%, to 29,398.08.
Smaller company stocks finished lower. The Russell 2000 index slid 6.15 points, or 0.4%, to 1,687.58.
European and Asian markets ended mixed.
Investors had largely set aside uncertainty about the potential economic fallout from the virus outbreak that originated in China the past two weeks. Stocks ended lower on Thursday for only the second time this month.
Businesses have been hurting due to the outbreak and more of them are warning that the effects will linger through the year.
Still, uncertainty over the economic impact of the outbreak has been tempered by signals out of China's government, which has taken steps to shore up businesses from the fallout.
The Federal Reserve has also helped reassure investors. This week, Fed Chairman Jerome Powell said it was too early to assess the threat the virus poses to the U.S. economy, but he noted that the economy "is in a very good place" with strong job creation and moderate growth.
Technology companies led the gainers Friday. Chipmaker Nvidia was a standout, jumping 7% after it handily beat analysts' profit forecasts for the fourth quarter.
The real estate and utilities sectors also held up well as government bond yields fell, making companies that pay higher dividends more attractive. Digital Realty Trust climbed 3.9% and American Water Works rose 1.7%.
Bond prices rose. The yield on the 10-year Treasury fell to 1.58% from 1.61% late Thursday.
Auto manufacturers, retailers and other companies that rely on consumer spending were among the decliners. Ford Motor dropped 1.8% and General Motors fell 1.5%. Target slid 1.4%.
Energy, industrial and financial sector stocks also declined. Marathon Oil slid 4.42, J.B. Hunt Transportation Services fell 3.6% and American International Group dropped 4.8%.
The price of U.S. crude oil closed 1.2% higher and notched its first weekly gain in six weeks. Benchmark crude oil rose 63 cents to settle at $52.05 a barrel. Brent crude oil, the international standard, gained 98 cents to close at $57.32 a barrel.
The slide in oil prices has weighed on energy stocks. The sector is the biggest loser in the S&P 500, down 10.2% so far this year.
Investors continued to assess corporate earnings reports Friday. Online travel company Expedia surged 11% and Sharpie maker Newell Brands rose 3% on solid earnings.
Canadian cannabis company Canopy Growth surged 15.8% after its latest quarterly results topped Wall Street's forecasts.
More than three quarters of S&P 500 companies have reported earnings and the results so far show solid growth. Companies are expected to report overall profit growth of just under 1% when all the reports are in, according to estimates from FactSet.
Several big companies are on deck to report results next week. Walmart will release its report on Tuesday and Deere will report on Friday.
Investors are heading into a shortened week that is light on economic reports. Stock and bond markets are closed on Monday for the Presidents' Day holiday. On Wednesday, the government will issue its report on producer prices, which measures inflation pressures before they reach consumers. Also, the Federal Reserve will release minutes from its January meeting.
Wall Street will also get some updates on the health of the housing industry. The government will release data on housing starts on Wednesday and the National Association of Realtors will release January home sales data on Friday.
In other commodities trading Friday, wholesale gasoline was unchanged at $1.58 per gallon. Heating oil climbed 2 cents to $1.70 per gallon. Natural gas rose 1 cent to $1.84 per 1,000 cubic feet.
Gold rose $7.60 to $1,582.70 per ounce, silver rose 12 cents to $17.72 per ounce and copper fell 1 cent to $2.61 per pound.
The dollar fell to 109.76 Japanese yen from 109.79 yen on Thursday. The euro weakened to $1.0842 from $1.0843.