When the stock market sinks, not all stocks sink with it. Some manage to do quite well during a downturn, whether it be because they cater to cost-conscious consumers, such as Dollar Tree (DLTR 1.07%), or because they operate in the recession-resistant healthcare industry, such as McKesson (MCK -2.06%). It could also be because they have built-in diversification that insulates them from a downturn, such as industrial supplier Carlisle Companies (CSL 1.66%).

All three of these companies are easily beating the S&P 500 index, which has declined roughly 25% so far this year.

Dollar Tree benefits bargain seekers

Dollar Tree operates 16,231 bargain stores in 48 states and Canada under the names Dollar Tree, Family Dollar, and Dollar Tree Canada. As the name implies, it sells much of its merchandise for $1, though it has raised prices in the past year. The company's stores are meant for bargain seekers, and the company has thrived in the past during economic downturns.

With inflation rising, even more affluent shoppers have starting flocking to the stores. Company CEO Mike Witynski said during the company's second-quarter earnings call that the company's fastest-rising demographic was from households earning more than $80,000 a year.

So far this year, the stock is down less than 1%, and while that's obviously better than the S&P 500, the stock could go higher if the economy does sink into a recession. In the meantime, the stock is still a bargain, even if we don't go into a recession, trading at only 20 times earnings.

The only reason the stock hasn't flown higher this year is that in its second-quarter report, citing inflationary pressures, Dollar Tree downgraded its guidance for the rest of the year, though its new guidance of yearly EPS between $7.10 and $7.40, still represents a gain from the $5.80 in EPS posted last year.

That said, the other financials in the report were rosy. The company reported revenue of $6.77 billion, up 6.7% year over year, and earnings per share (EPS) were $1.60, up 30.1% over the same period last year.

McKesson has strong pricing power

McKesson's shares are up more than 45% this year. The company is a supplier of drugs and medical equipment to healthcare companies. It doesn't make anything. It buys up goods at wholesale prices and sells them at retail prices. As such, it isn't dependent on a big research and development budget or whether a new drug will be approved by the Food and Drug Administration.

McKesson is a huge, diverse company, with a market capitalization of more than $50 billion and 75,000 employees. It operates in three segments: medical-surgical, U.S. pharmaceutical, and prescription technology. The medical facilities that treat consumers pretty much use the same number of scalpels and drugs during a recession as they do in boom times. That's one reason Warren Buffett, through Berkshire Hathaway, has been adding to positions in McKesson this year.

In the first quarter of fiscal 2023, McKesson reported revenue of $67.2 billion, up 7% over the same period last year, with EPS of $5.83, up 5% year over year. The company said it expects yearly EPS between $23.95 and $24.65, compared to $7.23 in 2022.

McKesson just raised its dividend by 15% to $0.54 per share, giving it a yield of around 0.61% and a very low cash dividend payout ratio of 6.1%, meaning it can easily continue to boost its dividend. In the first three months of fiscal 2023, the company did $1 billion in stock repurchases while authorizing another $4 billion in repurchases. Both moves help keep the stock's price high.

^SPX Chart

^SPX data by YCharts

Carlisle is in recession-resistant businesses

Carlisle Companies are so named because its business is actually four companies that make and supply engineered materials to be used by original manufacturers. It tends to fly under the radar because it sells its goods to companies, not consumers, as Carlisle Construction Materials, Carlisle Waterproofing Technologies, Carlisle Interconnect Technologies, and Carlisle Fluid Technologies.

The stock is up 17.5% so far this year because the company's businesses continue to grow. Still, like Dollar Tree, it trades at only 20 times earnings.

In the second quarter, it reported revenue of $1.8 billion, up 56.8% year over year, and EPS of $5.62, up 217.5%. Carlisle Waterproofing led the way with a revenue gain of 109.3% over the same period last year, while Carlisle Construction saw revenue jump 54%. The laggards, Carlisle Interconnect Technologies and Carlisle Fluid Technologies, also saw gains, though they were a more modest 25.9% and 0.6%, respectively.

Carlisle is also a Dividend Aristocrat that has raised its dividend for 46 consecutive years, including a 39% bump this year to $0.75 per share, giving it a yield of around 1.03%.