Shoppers are still willing to pay more for drinks and snacks, Pepsi says.

PepsiCo defied some expectations for an inflation-induced slowdown, raising its revenue forecast for the year for a second time, citing the “resilience” of consumer spending. But in its quarterly earnings report on Tuesday, PepsiCo left its profit forecast unchanged, suggesting that shoppers may cut back as prices continue to rise at an uncomfortably high rate.

The company, which makes Pepsi, Mountain Dew and Doritos, did not raise its profit outlook in line with its revenue forecast because of uncertainties about “consumer elasticity,” Hugh F. Johnston, the company’s chief financial officer, said on a call with investors. In other words, shoppers may eventually buy less if prices keep rising. The company now expects revenue to grow 10 percent this year, up from an 8 percent expectation last quarter, and for-profit to gain 8 percent, the same as it expected before.

Notably, PepsiCo’s second-quarter revenue and profit, which both beat analyst expectations, grew faster than sales volumes, implying that the company was able to charge more for each can of soda and bag of potato chips.

Can it keep that up for the rest of the year? “We still have six months to go,” Mr. Johnston said, and there are “plenty of unknowns in terms of what’s going to happen with consumer behavior.”

PepsiCo is one of the first big companies to report earnings for the second quarter of the year, and the tone it has set is of cautious optimism. Analysts and investors are watching bellwether companies like PepsiCo for signs about the state of consumer spending and the risk of a recession, as the economy appears increasingly fragile.

PepsiCo’s stock finished lower on Tuesday. Since the start of the year, it has handily beat the market, with company shares down about 2 percent, compared with the S&P 500, which is down about 20 percent over that time.

PepsiCo’s report suggests that consumers are still able to absorb some price increases, which do not appear to be abating. Further out, however, the company appears more cautious about how potential consumer cutbacks and its own rising costs could eat into profit margins. Forecasts for the quarters to come will be closely scrutinized in other earnings reports due in the coming weeks, as market watchers try to get a feel for how the economy might shape up in the rest of the year.

“As inflation keeps going up,” Ramon L. Laguarta, PepsiCo’s chief executive, said on the call, “we’re going to have to be superagile and very precise on the choices we make with the consumer.”