Pepsi (PEP  ) stock was higher following the company's Q2 earnings which showed it beating analysts' expectations on the top and bottom line in addition to issuing better than expected revenue guidance for the full year.

As one of the first major companies to report Q2 earnings, investors were paying attention to what the company was saying about consumer demand and other economic issues. Demand has remained steady, although the company is seeing more sales of smaller packaged items. It also was able to raise prices for some products.

Overall, Pepsi has been a relative outperformer this year as the stock is down 1.5% which is significantly better than the S&P 500's (SPY  ) YTD 23% decline. Pepsi is more of a defensive stock as revenues for its products are not as economically sensitive. The company also pays a 2.7% dividend yield and has a history of consistently increasing its payout.

Inside the Numbers

In Q2, Pepsi reported $1.86 in adjusted earnings per share, beating expectations of $1.74 per share. Revenue came in at $20.23 billion vs $19.5 billion. Revenue was higher by 5%, however, unadjusted earnings per share declined from $1.70 per share in last year's Q2 to $1.03 per share, although it would have achieved a 10% EPS increase without taking the Russia-Ukraine war into account.

However, the revenue was in large part due to higher prices for items like chips and drinks. The company expects costs to keep rising in the second half of the year, and it's finding solutions like reducing product size to keep costs under control. The company also took a hit from the Russia-Ukraine war, as it took a $1.17 billion write-off due to pausing sales in the country.

Breaking it down by categories, Pepsi's Frito-Lay North American organic revenue rose 14% due to growing sales for Cheetos and Doritos. However, volumes were down by 2%. North American beverage sales increased 9%, but volumes declined by 1%.

Quaker Foods North America saw revenue growth of 18% and volume growth of 2%. This is more of a defensive segment that sees higher sales when people are cooking more meals at home. However, the company could see some impacts from currency changes given its exposure to overseas economies and recent dollar strength.