Earnings season is here, and investors are bracing for what could be some poor quarterly results in the wake of rising costs and potentially tighter spending as people prepare for what could be a recession down the road. Many companies have already been struggling and are facing some tough outlooks for the future.

However, two businesses that seem to be resilient of late are Walgreens Boots Alliance (WBA -2.57%) and PepsiCo (PEP 1.42%). Both companies recently reported encouraging earnings numbers.

1. Walgreens

There are close to 9,000 Walgreens locations across the U.S. that serve an estimated 9 million people every day. The pharmacy retailer is a trusted brand for millions of Americans, and its stores have helped administer many COVID-19 vaccinations.

But the business itself has been a bit of an underdog with lackluster sales growth. There are also fears of rising competition from companies like Walmart and Amazon that continue to make moves into healthcare, potentially threatening Walgreens' position in the industry. Earlier this month, however, the company proved its resiliency yet again with some better-than-expected numbers.

For the period ended Aug. 31, Walgreens' sales of $32.45 billion came in better than the $32.09 billion that analysts were expecting. And its adjusted earnings per share (EPS) of $0.80 was also higher than the $0.77 adjusted per-share profits that Wall Street was expecting. The company still incurred a net loss of $415 million for the period, but that was mainly a result of a $783 million impairment charge related to its Boots UK business.

The positive for investors is that the business is showing resiliency, with quarterly sales down just a modest 3.2% year over year (when factoring out the effect of foreign currency). Those aren't bad numbers at a time when consumers are scaling back purchases amid rising inflation. 

Walgreens has seen its shares crater more than 35% since the start of 2022. Investors worry about its future and ability to draw traffic to its stores, now that demand for COVID vaccinations may be subsiding as the economy returns to normal. There's some risk with the stock, but given the stability it has demonstrated, Walgreens could make for an underrated buy. An added incentive to buy the income-generating stock is that with the decline in share price, it now pays a dividend yield of close to 5.8%.

2. PepsiCo

Last week, soft drink giant PepsiCo also released its latest quarterly numbers. The company, which has several top brands in its portfolio, including Pepsi, Lay's, and Doritos, also showed strong resiliency in its business. The consumer goods company was able to raise prices to offset the effect of rising costs, and the net result was a positive 9% increase in year-over-year revenue. Sales of $21.97 billion for the period ending Sept. 3 beat analyst expectations of $20.84 billion. Adjusted EPS of $1.97 also came in much higher than analyst projections of $1.84.

The company has generated positive year-over-year sales growth in every major segment this past quarter, including 20% reported growth in Frito-Lay North America (one of its largest segments) and in Latin America. Due to the strong results, PepsiCo also raised its forecast for the year, now expecting organic revenue growth to come in at 12% versus the 10% it previously projected. 

Customers are proving to be reliant on PepsiCo's products, and the brand loyalty is evident through the company's strong growth numbers, especially amid inflation. Year to date, shares of PepsiCo are down less than 1% (the S&P 500 has declined by 23% over the same stretch) as the stock has proven to be one of the safer options to invest in, and there's little reason to doubt that will change anytime soon. PepsiCo also pays a dividend that yields 2.7%.