The S&P 500 headed toward its first weekly gain in three weeks, as broad advances across sectors helped offset a slide in retail stocks.

Major indexes' moves were muted most of the week -- something investors and analysts attributed to the dearth of major economic reports on the calendar and a lull in trading toward the end of August.

The number of shares changing hands over a full session of trade on exchanges owned by the New York Stock Exchange and the Nasdaq fell to their lowest level of 2017 on Wednesday, and hovered below average levels the rest of the week.

Continue Reading Below

ADVERTISEMENT

Still, while major indexes largely trudged along, corporate news continued to drive swings in individual sectors.

Shares of consumer-staples companies in the S&P 500 lagged behind, on course to end the week down 0.8%, after disappointing earnings pulled shares of J.M. Smucker and Hormel Foods lower on Thursday.

Food retailers also suffered. General Mills, Kellogg and Campbell Soup were down about 3% apiece for the week after Amazon.com said Thursday that it planned to cut prices of top-selling grocery staples at Whole Foods after its deal to acquire the chain closes.

"Investors are sorting out the winners and losers, and you see that clearly in the battle in Amazon versus traditional retailers," said Stephen Rigali, executive vice president at Kayne Anderson Rudnick Investment Management.

The Dow Jones Industrial Average rose 71 points, or 0.3%, to 21855 on Friday, on course for a 0.8% weekly gain. The S&P 500 inched up 0.4%, heading toward a 0.9% weekly gain, and the Nasdaq Composite added less than 0.1%, on track to end the week 1% higher.

U.S. stocks and government bond prices extended gains Friday after Federal Reserve Chairwoman Janet Yellen offered few new clues on the path of monetary policy at the central bank's annual retreat in Jackson Hole, Wyo.

The yield on the 10-year U.S. Treasury note settled at 2.169%, compared with 2.194% on Thursday. Yields fall as bond prices rise.

The dollar pulled back, with the WSJ Dollar Index -- a measure of the dollar against a basket of 16 currencies -- falling 0.6%. The index has fallen more than 7% this year as a string of lukewarm economic data has left investors betting the Fed won't rush to raise rates.

Ms. Yellen's failure to address the possibility of interest-rate increases weighed on the dollar while driving bonds higher, analysts said. Higher rates tend to make the dollar more attractive to yield-seeking investors while weakening demand for government bonds.

Elsewhere, the Stoxx Europe 600 fell 0.1%, weighed down by declines in shares of travel and leisure companies.

The Shanghai Composite Index jumped 1.8% on Friday, while South Korea's Kopsi edged up 0.1%, weighed down by declines in shares of Samsung Electronics Co. Samsung's de facto leader, Lee Jae-yong, was found guilty of bribing South Korea's president and sentenced to five years in prison on Friday.

Write to Akane Otani at akane.otani@wsj.com and Riva Gold at riva.gold@wsj.com