There are signs that the economy is slowing down, and even Costco Wholesale (COST 1.01%) isn't immune to those effects. As consumers tighten their budgets and cut unnecessary expenses, that leads to less spending across the board. And the company's most recent earnings numbers do suggest some softness right now -- but the results aren't as bad as they appear.

Earnings miss expectations, but Costco's profit is within its usual range

On May 25, Costco reported its fiscal third-quarter earnings numbers for the period ended May 7. Earnings per share of $2.93 for the quarter fell well short of what analysts were expecting at $3.29. The problem with razor-thin margins is there's not much room for error for the company. And selling, general, and administrative costs, one of its key expenses, rose by 8% last quarter while sales only increased by 2%.

A softer economy is making it more challenging for retailers to grow their earnings and even Costco isn't proving to be infallible anymore. But while there has been volatility in its bottom line, Costco's profit margin remains largely intact with its five-year average:

COST Profit Margin (Quarterly) Chart

COST Profit Margin (Quarterly) data by YCharts

It may appear to be a big miss with respect to expectations, but in the grand scheme of things, there's no cause for alarm as Costco's overall level of profitability hasn't changed drastically.

Sales were positive on an adjusted basis

Costco's comparable sales growth last quarter was negative in its two key markets, Canada and the U.S., down 1% and 0.1%, respectively. But when adjusting for the impact of foreign exchange and the change in gas prices, the growth rates rise to 1.8% for the U.S. and 7.4% for Canada.

There's no denying that there is a slowdown in retail these days but compared to other retail stocks, particularly those where discretionary spending plays a significant role, Costco's growth rate hasn't been all that bad:

COST Revenue (Quarterly YoY Growth) Chart

COST Revenue (Quarterly YoY Growth) data by YCharts

Generating any kind of positive sales growth while also maintaining profitability is a net positive for a retailer. Costco continues to outperform many of its peers and shows why it often warrants a premium (it trades at more than 35 times earnings) as it is one of the safer retail stocks to own. Over the past five years, it has soundly beaten the S&P 500 with gains totaling 160% versus just 56% for the index.

Is Costco stock a buy?

Despite the earnings miss, shares of Costco have been rising since its Q3 numbers came out last month. It's less than 10% away from its 52-week high of $564.75. There simply hasn't been a big sell-off even amid the soft economic conditions as the stock is still up more than 8% over the past 12 months.

Costco has been a safe-haven stock for many investors as it's one of the best retail stocks to own, and it also offers a modest dividend yield of 0.8%. There's also the chance that it may end up paying a special dividend to further boost those payouts.

For long-term investors, this remains an excellent stock to buy as Costco has proven time and time again that it has one of the most resilient businesses in the world.