(AP) -- The stock market drifted lower Friday but finished October with its biggest monthly gain in four years.
U.S. government economic data released Friday and earlier this week suggests the economy is still sluggish, stuck in a pattern of gradual but uneven growth it has followed since the Great Recession. But the outlook for future growth improved and fears waned that a slowing Chinese economy would send the U.S. economy into a tailspin.
Strong corporate earnings in some sectors, like health care and telecommunications, also helped propel the market all the way back to positive for the year after a swoon in August and a rocky September.
Paul Christopher, global market strategist for Wells Fargo, said investors are now gaining confidence in the U.S. economy and are more hopeful that China won't suffer an abrupt downturn.
"We could see investors finally put that correction in August and those fears permanently behind them," he said.
The Standard & Poor's 500 index has risen for five consecutive weeks and it ended October up 8.3 percent, its best month since October 2011. The index's increase of 159 points was the biggest in its 77-year history. The next-best month was March 2000, the height of the dot-com bubble, when it rose 132 points.
Sam Stovall, U.S. equity strategist at S&P Capital IQ, said a very strong October usually means the market won't make big gains in November and December, muting the so-called Santa Claus rally. He does expect stocks to keep rising for the rest of this year, though, and make gains in 2016, lifted by overall economic growth and improving corporate earnings.
He said 2016 "has a chance of being a good year but not a great year" for equities. "Investors will continue to buy the dips until the prospect of either a U.S. or global recession spooks investors again."
On Friday, stocks were largely flat through much of the day, venturing into positive territory in the early afternoon before ending lower. The S&P 500 lost 10.05 points, or 0.5 percent, to 2,079.36. The Dow Jones industrial average dipped 92.26 points, or 0.5 percent, to 17,663.54. The Nasdaq composite index slid 20.53 points, or 0.4 percent, to 5,053.75.
The Commerce Department said Friday that consumer spending inched up just 0.1 percent in September, partly because consumers were spending less on gasoline as energy prices fell. The gain was the smallest in eight months. The department said Thursday that economic growth slowed sharply in the summer, although most economists think the economy has improved this month.
Wells Fargo's Christopher said the November and December U.S. unemployment reports will help set the course of the markets for the rest of this year, along with the Federal Reserve's interest rate policies.
The busiest week of third-quarter earnings wrapped up Friday with big moves for a slew of companies. The professional networking service LinkedIn surpassed analyst estimates and its stock gained $23.87, or 11 percent, to $240.87. Drugmaker AbbVie surged as sales of its anti-inflammatory Humira, the biggest-selling drug in the world, continued to rise. AbbVie rose $5.45, or 10.1 percent, to $59.55.
Chevron, the second-largest U.S. oil company, said its profit fell almost two-thirds. The company said it will eliminate around 10 percent of its jobs, or up to 7,000 positions, and will also slash capital and exploration spending as it deals with lower oil prices that are cutting deeply into profit.
Valeant Pharmaceuticals suffered more losses Friday as controversy around its drug prices and sales practices climbed. The stock sank $17.73, or 15.9 percent, to $93.77. On Thursday the two largest pharmacy benefits management companies in the U.S., CVS and Express Scripts, cut ties with a Valeant-linked specialty pharmacy called Philidor. Philidor has been criticized as a "phantom pharmacy" used to artificially boost Valeant's sales. On Friday Valeant said Philidor has informed it that it will shut down as soon as possible.
Bond prices rose. The yield on the 10-year Treasury note fell to 2.14 percent.
Benchmark U.S. crude rose 53 cents, or 1.2 percent, to $46.59 a barrel in New York. Brent crude, which is used to price international oils, advanced 76 cents, or 1.6 percent, to $49.56 a barrel in London. Wholesale gasoline rose 5.5 cents, or 4.1 percent, to $1.405 a gallon. Heating oil picked up 2.5 cents, or 1.7 percent, to $1.499 a gallon. Natural gas rose 6.4 cents, or 2.8 percent, to $2.321 per 1,000 cubic feet.
Gold fell $5.90, or 0.5 percent, to $1,414.40 an ounce. Silver rose 1.7 cents, or 0.1 percent, to $15.57 an ounce. Copper slipped a fraction of a cent to $2.257 a pound.
The dollar lost value against the yen, falling to 120.67 yen from 121.11 on Thursday. The euro rose compared to the dollar, reaching $1.099 from $1.0974.