Wall Street has warmed up to consumer staples stocks in recent months as the prospects rise for a recession in 2023. These investments aren't immune to a recession, but they often perform well during downturns while delivering steadily rising dividend payments.

McCormick (MKC 1.68%) and Procter & Gamble (PG 0.54%) are both ideal stocks if you're looking for exposure to these positive investing traits. They are leaders in their respective industries and have long track records for hiking dividends through recessions. So let's stack the two against each other to see which one might be a better fit for your portfolio.

Recent growth trends

Both companies are seeing demand pressure as they raise prices in the face of slowing consumer spending. Yet their latest results make it clear that they each have pricing power.

Procter & Gamble raised prices by 10% on average across its product portfolio in the latest quarter, while McCormick lifted prices by 9%. In both cases, sales volumes fell, indicating some trading-down on the part of consumers.

But P&G still grew organic sales by 5% and McCormick's comparable figure was 4%. As a result, there's no clear standout when it comes to growth. Both companies are finding ways to keep sales churning higher even following soaring gains in the prior two years.

The margin matchup

P&G starts to step ahead when we look at key financial metrics like profitability and cash flow. Its operating margin remains above 20% of sales, which is a testament to its market-share lock in many niches such as paper towels, diapers, and laundry detergent.

McCormick, in contrast, has seen its margins fall significantly in the last several quarters. Management is projecting a return to higher profitability in 2023, and several of the headwinds that hurt earnings last year were transitory. But P&G is still the clear winner on the earnings front.

MKC Stock Buybacks (TTM) Chart

MKC stock buybacks (TTM) data by YCharts. TTM = trailing 12 months.

The company also generates ample free cash flow that it can direct toward dividend payments and stock buybacks. McCormick, in contrast, has kept its share-repurchase spending at near zero for several years running. If you're a big fan of direct cash returns from both dividends and buybacks, then you'll prefer P&G right now.

The valuation

As you might expect, investors are being offered a big discount on McCormick shares today compared to Procter & Gamble. You have to pay just 3.3 times annual sales for the stock while P&G is going for about 4.4 times sales. The gap is similar on earnings, with P&G's valuation sitting at 30 times profits while McCormick is going for 25 times the past year's earnings.

Still, P&G seems to have earned that premium. The company is doing a better job at protecting profit margins and dealing with supply chain disruptions. These successes might prove even more valuable if consumer demand slows further in 2023.

Buying McCormick today might set you up for better returns over the next several years, if the company can achieve the turnaround that management is predicting this year. But P&G is the less risky choice for investors.