Are we headed toward a recession? Some analysts seem to think so. And with the stock market still feeling the weight of geopolitical tensions, not to mention rising interest rates, the current slump that equities are experiencing could linger for a while.

Investors looking to buy stocks under these conditions would do well to select companies that have what it takes to survive severe downturns. Let's look at two companies that fit the bill: Amgen (AMGN 0.17%) and Microsoft (MSFT 0.47%).

1. Amgen

Biotech Amgen has been around since 1980, and in that time the company has survived several recessions. Of course, that's no guarantee that it will do so again, but the company's business is well-positioned to remain at least somewhat healthy even during the worst economic downturns. Other than basic necessities (food, shelter, etc.) patients will cut back on almost anything else before lifesaving medicines.

That gives pharmaceutical companies a bit of an edge in difficult times. Turning to Amgen's lineup, the company features several promising drugs, including important new approvals. In the first quarter, Amgen's revenue increased by a respectable 6% year over year to $6.2 billion.

One of Amgen's top-selling drugs for the quarter was Prolia, which treats osteoporosis (a condition that causes bones to become weak). Sales of the medicine grew by 12% year over year to $852 million. Other high performers for Amgen included Repatha, a drug used to lower bad cholesterol. Repatha's revenue jumped by 15% year over year to $329 million.

Amgen's lineup of new medicines includes asthma treatment Tezspire, which earned approval from the U.S. Food and Drug Administration (FDA) in December. Although there are plenty of competing asthma therapies, Amgen and its partner on this program, U.K.-based pharma giant AstraZeneca, have high hopes for Tezspire since they believe that current asthma treatments are inadequate for many patients.Tezspire's revenue in the first quarter came in at $7 million.

Then there is Amgen's cancer medicine, Lumakras. It first earned FDA approval in the U.S. in May 2021 and has since been given the regulatory nod in the EU. Lumakras is the first and only lung cancer treatment approved in both regions that specifically targets a mutation affecting some 13% of those with non-small cell lung cancer. The medicine's revenue in the first quarter was $62 million.

Both Lumakras and Tezspire should see their sales rise steadily in the coming years. Elsewhere, Amgen boasts several dozen ongoing clinical trials. Even a handful of new approvals would benefit the company's top and bottom lines. In addition, Amgen offers a dividend yield of 3.25% and a cash payout ratio of 48%, making it a good prospect for income-seeking investors.

Investing in a company with a solid business and a strong dividend can help investors get through any recession, and that's what Amgen offers. 

2. Microsoft

Some of Microsoft's products are so entrenched in the lives of individuals and businesses that the company should continue to do well during a recession. Consider its productivity tools, including OfficeSuite. Thousands of companies rely on such applications as Excel, Word, Teams, and Outlook (among others) in their day-to-day operations.

Microsoft remains the leading provider of computer operating systems in the world, with a roughly 73% share of the market as of December 2021, according to Statista. Here's one more factor that may work in Microsoft's favor in a recession: The company is a cash-generating machine with $63.7 billion in free cash flow at the end of its latest reporting period.

Having plenty of cash on hand makes it easier to navigate difficult times, and that's as true for businesses as it is for individuals. A downturn may slow down Microsoft's business, but that would be temporary. The company still possesses the tools to succeed in the long run.

This also includes the company's strength in two other industries: gaming and cloud computing. The latter looks particularly promising. Cloud computing allows businesses to enhance efficiency and productivity, which in turn helps them pass on cost savings to their consumers.

Thanks to Azure, Microsoft has become one of the top names in this industry, which is still on a solid upward path. According to some estimates, the sector will expand at a compound annual growth rate of 17.43% through 2030. Expect Microsoft to be one of the leading beneficiaries of this trend.

So even if a recession comes relatively soon, the company should continue delivering solid returns in the long run.