Wall Street can't seem to get enough soda and snacks right now. PepsiCo (PEP 1.08%) and Coca-Cola (KO 2.14%) stocks are trouncing the S&P 500 this year and completely missing out on the bear market that has sent indexes lower by over 20%.

It's not hard to see why investors are so excited about these businesses. Coke and Pepsi each raised their fiscal-year outlooks recently after announcing speeding sales growth and strong profitability. Their earnings prospects look strong, despite challenges like inflation.

With that big picture in mind, let's look at which stock looks more attractive as a long-term investment right now.

Both goods producers are getting results

Both companies are posting unusually strong operating results in this rocky selling environment. Organic sales are up 16% through the last nine months at both Pepsi and Coke, in fact, which represents accelerating growth.

These gains are partly coming from higher prices, but also from fundamentally strong demand. PepsiCo said in mid-October that shoppers aren't choosing to trade down in their snack and beverage choices, even as prices increase.

Coca-Cola sounded a similar tone more recently, saying on Oct. 25 that the company is winning market share across a wide range of price points. Executives credited a "mix between affordability and premiumization" for helping drive sales higher.

Margin focus points to Coca-Cola

If you look beyond that headline revenue number, more differences show up between these two investments. Coke has a much higher profit margin than PepsiCo, which operates a more diverse business that includes snack and breakfast foods. Meanwhile, Coke's focus on more on-the-go beverages has exposed it to a bigger demand spike in recent months as consumers prioritize travel and dining experiences.

KO Operating Margin (TTM) Chart

KO Operating Margin (TTM) data by YCharts.

This difference shows up in operating profit margin. For Coke, it landed at a blistering 29.5% of sales in Q3, compared to 30% of sales a year ago. PepsiCo's comparable figure clocks in at about half that rate, although it's also holding up well in today's inflationary environment.

Coke also stands a bit taller when it comes to cash generation. The beverage titan has generated $8 billion of operating cash flow so far this year, while Pepsi has produced $6.3 billion. Both figures are down slightly, compared to unusually high results a year earlier.

The two companies plan to send most of that cash to shareholders, too. Pepsi is targeting $8 billion of cash returns in 2022, mostly through dividends. Coke is being a bit less aggressive here, with cash returns on track to rise modestly, compared to last year's $7.3 billion.

But which soda stock is the better deal?

Given these impressive growth and financial metrics, it makes sense that Coke and Pepsi stocks would both be beating the market in 2022. But there's a large valuation gap. Coke is valued at about twice PepsiCo's price-to-sales ratio of 3, in fact.

An investor might happily pay that premium if they were seeking a more focused beverage portfolio with higher profitability. Coke also pays a slightly higher dividend yield today.

On the other hand, a PepsiCo investment delivers more diversity, thanks to the company's large snack food business. Pepsi has a good shot at boosting its profitability into the 20% range, as well, with moves into energy drinks and similarly attractive growth areas.

If you're seeking growth, income, and market-leading profit margins, Coke looks like the stronger investment in the final quarter of 2022.