Shares of PepsiCo Inc. surged Wednesday toward its best performance in 2 1/2 years, after the beverage and snack giant reported third-quarter profit and revenue that rose above expectations and raised its full-year outlook, as higher prices helped offset some volume weakness.

Net income for the quarter to Sept. 3 rose to $2.70 billion, or $1.95 a share, from $2.22 billion, or $1.60 a share in the same period a year ago.

Excluding nonrecurring items, core earnings per share of $1.97 beat the FactSet EPS consensus of $1.84.

Revenue grew 8.8% to $21.97 billion, well above the FactSet consensus of $20.84 billion. Unfavorable currency translation reduced revenue growth by 3 percentage points.

That marked the 15th-straight quarter that PepsiCo beat profit expectations and the 20th-straight quarter revenue projections were exceeded, according to FactSet data.

The stock PEP, +4.77% climbed 3.6% in morning trading, putting it on track for the biggest one-day gain since it ran up 5.7% o April 14, 2020. It is also headed for the best one-day post-earnings performance since it rallied 4.8% on July 18, 2018, after second-quarter 2018 results.

Among PepsiCo’s largest segments, revenue from PepsiCo Beverages North American rose 3.6% to $6.64 billion, Frito-Lay North America jumped 19.6% to $5.56 billion, Europe increased 0.9% to $3.65 billion and Latin America grew 19.9% to $2.52 billion. Quaker Oats North America revenue was up 15.4% to $713 million.

Volume declined 1.5% in convenient foods and edged up 3.0% in beverages. On an organic basis, which excludes the impact of acquisitions, divestitures and other structural changes, overall volume fell 1% while effective net pricing increased 17%.

When asked on the post-earnings conference call with analysts about price elasticity, or how consumers are responding to price increases, Chief Financial Officer Hugh Johnston said elasticity continues to be “strong and stronger than expected” year to date.

“We obviously exited the third quarter with the consumer still very healthy in terms of our particular categories,” Johnston said, according to a FactSet transcript. “I’m not sure that’s true broadly, with housing and other big-ticket purchases. So we’ll see what elasticities look like in the fourth quarter,” Johnston added.

Cost of sales increased more than revenue growth, up 9.7% to $210.31 billion, as gross margin contracted to 53.1% from 53.5%.

The company said on the call that the goal is always to “price through inflation,” but it came up a bit short of that in the third quarter, as noted by the decline in gross margin.

Inventories increased 15.5% to $5.02 billion, after rising 21.6% in the second quarter and increasing 9.5% in the first quarter.

Looking ahead, the company raised its full-year core EPS guidance to $6.73 from approximately $6.63. The FactSet 2022 EPS consensus was $6.69.

The company affirmed its plan to return $7.7 billion to shareholders this year, including $6.2 billion through the payment of dividends and $1.5 billion through the repurchase of shares.

PepsiCo’s stock has slipped 3.0% year to date, while the SPDR Consumer Staples Select Sector exchange-traded fund XLP, +1.43% has declined 11.6% and the S&P 500 index SPX, +0.16% has dropped 24.6%.