Concerns about a potential recession have rattled stocks over the past year and made investors more cautious. While Wall Street always likes to see strong growth, right now the priority is on stability and profitability through what could be a weak period ahead for the economy.

So, let's take a closer look at two companies that embody these characteristics. By dominating their respective industry niches, Procter & Gamble (PG 0.72%) and Costco Wholesale (COST 1.03%) are positioned for sales and earnings growth even as many of their rivals struggle. Let's see which of these successful stocks is a better fit for investors today.

Latest results

Both companies are outgrowing their industries right now. Procter & Gamble said in mid-January that organic sales rose 5% in the most recent quarter on top of big gains a year earlier. Demand for staple brands like Tide detergent and Pampers diapers is holding up despite large price hikes.

Likewise, Costco's same-store sales were up an impressive 7% in the quarter that ended in mid-February as shoppers look to stretch their shopping budgets.

Yet, Costco has an edge on growth here. The warehouse retailer's value tends to be clearer to its members during inflationary times, and there's plenty of evidence showing rising customer loyalty. Costco is seeing consistently rising traffic at its stores, and its membership renewal rate just hit a new high of 92.5%.

P&G, on the other hand, is seeing declining sales volumes in response to its price increases.

Profit margin

Investors who prioritize earnings will gravitate toward Procter & Gamble stock. The consumer staples giant is more profitable than Costco, but its 22% operating margin also puts it well above industry peers like Kimberly-Clark. In contrast, Costco earns about the same 3% rate as its rivals, including Walmart.

PG Operating Margin (TTM) Chart

PG Operating Margin (TTM) data by YCharts

P&G has demonstrated its pricing power in recent months by raising prices significantly. These hikes have protected profitability at the expense of weaker volumes.

Costco is positioned well for a price increase of its own, with a membership fee hike likely at some point in the next year or so. But the retailer won't dazzle shareholders with its annual earnings haul because most of its profits go back into maintaining its price leadership position.

Cash returns and valuation

P&G takes the edge when it comes to cash returns. The company has steadily boosted its dividend payout for over 60 consecutive years, and the stock currently yields 2.5%. Costco's management team isn't as committed to its annual dividend, choosing mainly to send periodic "special dividends" out to its shareholders. Costco stock yields 0.7% today, or about half the rate investors can get from Walmart shares.

Neither stock is especially cheap. P&G is priced 4.5 times sales, a big premium over industry peers. And Costco's P/S ratio of 0.9 puts it above Walmart and Target, which are both valued at closer to 0.6 times sales.

Despite the elevated valuation, both stocks are likely to be a positive addition to your portfolio. Investors who are more worried about a sharp recession would prefer Costco here, since its sales and earnings trends won't be as volatile in that scenario. If you're less risk-averse and a fan of dividends, on the other hand, take a closer look at P&G ahead of its like 68th consecutive annual dividend hike on the way in April.