If you're looking for a stock that you can hold for a lifetime, you have to look beyond a company's current performance, whether good or bad, and analyze the core strength that will keep it around for decades.

Two stocks I would consider holding forever are Nike (NKE 0.19%) and CarMax (KMX 0.54%). These industry leaders are experiencing slowing growth due to macroeconomic headwinds that have sent their stocks down to low valuations, but this is the perfect opportunity to buy shares at fire-sale prices. 

Nike and CarMax both trade around $100 or less, so an investor who doesn't have much money to invest should be able to buy a share of at least one of these stocks. Let's take a closer look at what is affecting these companies' performance and why these two stocks could be undervalued.

1. Nike

Nike is the top global athletic wear brand and has a long history of delivering market-beating returns to investors. But the stock was cut almost in half over rising costs that have pressured the company's profits. Nike will return to profitable growth again, but the stock is currently selling at its lowest valuation in five years on a price-to-sales basis. 

Revenue reached a record $51 billion in the fiscal year ending May 31, representing an increase of 10%. However, cost of sales grew 15%, which hurt margins. As a result, Nike reported an uncharacteristic 14% decline in earnings per share for the year, which is why the stock is down.

NKE Chart

NKE data by YCharts

Management reported on the earnings call in June that inventory was in a much better position relative to demand, which should limit price discounting to move merchandise and position the company for a return to profitable growth.

Right on cue, Nike just reported much better numbers for the fiscal quarter ending Aug. 31. While revenue growth is still muted, with only a 4% increase in footwear sales, earnings per share increased slightly year over year, sending the stock higher. 

Nike is the top footwear brand, with about two-thirds of its revenue coming from footwear. The Jordan Brand has strong momentum and is on track to become the second-largest footwear brand in North America. 

Nike can grow for decades due to high consumer brand awareness, but one factor that is helping spread more awareness for the brand is Nike's digital business. The company's investments to meet customers when and where they want to shop has paid big dividends. Over the last four years, the percentage of Nike's business coming from digital sales channels, including Nike.com and the SNKRS app, has more than doubled to 26% through fiscal 2023. The growth here should continue to fuel Nike's margins for years to come and is a good reason to consider buying its stock.

The stock is trading higher following its latest earnings report, but it's still trading well off its highs. Nike's price-to-sales valuation hasn't been this low since the pandemic-driven market crash in March 2020. 

2. CarMax

CarMax is the largest used car retailer, but the stock is down over a temporary downturn in the auto industry. Last year was one of the worst years for auto sales in a while, which caused a big dip in CarMax's sales. But as you can see in the chart, this is just a speed bump after years of steady growth.

KMX Revenue (Quarterly) Chart

KMX Revenue (Quarterly) data by YCharts

High inflation, rising interest rates, and tightening loan markets are a perfect storm for CarMax. Revenue is still down year over year, falling 13% in the fiscal quarter ending Aug. 31. Its auto finance business is feeling the squeeze, with income down 26% due to higher provisions for loan losses and an unfavorable shift in interest rates that is affecting the bottom line.

But long-term investors should be excited because you only get a chance to buy shares of great businesses in difficult times like these. In a stronger auto market, the company would be enjoying profitable growth, and the stock would be trading much higher.

Despite the ups and downs of the car market, investors can have confidence in the long-term future of CarMax for a few reasons.

CarMax has a solid competitive advantage based on its store footprint. As the U.S.'s largest retailer of used cars, CarMax benefits from gathering a tremendous amount of data on car sales, which allows it to make accurate appraisals and earn a reasonable profit on buying and selling. Customers go to CarMax for a friendly sales environment, where sales associates earn a fixed commission and are not incentivized to push customers toward higher prices to earn more money. 

While it faces competition from online car seller Carvana, CarMax has its own online sales channel. The company continues to invest in artificial intelligence and data science to make it easier for customers to find exactly what they want.

The proof is in the numbers. Carvana has experienced a worse decline in revenue than CarMax over the last year, which speaks volumes about the latter's competitive position.

CarMax stock sells at a ridiculously low price-to-sales (P/S) ratio of 0.41, which is the cheapest the stock has been in over 10 years. Considering that the company's share of the used car market is less than 5%, the stock could deliver fantastic returns off these lows as the company continues to gain more share of the market over time. Investors could double their money over the next five years if the stock returns to its average P/S ratio of around 0.8.