Many people question whether it is wise to buy stocks right now, given how volatile the market has been lately, not to mention various challenging economic problems such as inflation. Of course, it is always wise to save a healthy sum of money for potential unforeseen rainy days, but for those who can afford it, now is as good a time as any to get in on stocks.

While it's true that equity markets have been a bit erratic, long-term minded investors know that staying the course will generally pay off down the road. That's especially true provided you invest in solid companies. With that in mind, here are two stocks worth buying now and keeping for many years to come: HCA Healthcare (HCA -2.37%) and Veeva Systems (VEEV 0.91%).

1. HCA Healthcare

Hospital chain HCA Healthcare has had its share of trouble amid the pandemic. Occupancy levels in its facilities decreased amid the worst of the outbreak. And while foot traffic in the company's hospitals started picking up last year, surges in cases due to new variants of the coronavirus -- such as omicron -- affected its business once again. Despite these issues, HCA Healthcare delivered a solid performance last year.

In 2021, the company's revenue increased by 14% year over year to $58.8 billion. HCA Healthcare's adjusted earnings per share was $17.5 for the year, representing a 50.7% increase compared to the fiscal year 2020.

With the pandemic seemingly fading a little more, expect HCA Healthcare to continue performing well this year. Even if things don't go that way, the company's outbreak-related headwinds are merely temporary. More importantly, the company's long-term prospects are bright. Here's just one reason: the aging population in the U.S. According to some estimates, adults aged 65 and older will make up 25% of the U.S. population by 2060. That number stood at 16% in 2019.

Nurse talking to patient inside a healthcare facility.

Image source: Getty Images.

People use more and more medical services as they get older. HCA Healthcare makes revenue based on occupancy levels and the services physicians order for their patients. That's why aging trends will provide a boost to the company's top-line growth, provided it can remain a leading hospital chain in the years to come. That seems likely to happen.

HCA Healthcare has one of the most impressive networks across the U.S., with 182 hospitals as of the end of 2021. The company's facilities are particularly concentrated in Texas and Florida; it generated 49% of its revenue from these two states in 2021. HCA Healthcare also has a diversified portfolio of facilities, which includes acute care centers, surgery centers, psychiatric hospitals, and more.

That speaks to the company's ability to continue attracting patients, which will work wonders for HCA Healthcare's top and bottom lines in the long run. 

2. Veeva Systems

The life sciences industry is highly regulated, and that comes with substantial risks related to legal compliance. Veeva Systems makes it easier for life science companies to ensure legal and regulatory compliance by providing a set of cloud-based tools to facilitate bringing products to market. These tools also help life science companies improve efficiency and decrease costs.

Veeva is one of the leading providers of cloud-based solutions to life science companies, and given how valuable its offerings are, it isn't surprising that it has racked up growing revenue and earnings. Veeva's fiscal 2022 year ended on Jan. 31, 2022, and for this period, the company's revenue increased by 26% year over year to $1.9 billion. On the bottom line, the company's net income of $427.4 million grew by 12.5% compared to the previous fiscal year.

One great thing about Veeva System's business is that its services are sticky, as evidenced by its retention rates for its subscription solutions that are typically in the low to mid 120% range. Veeva Systems is in the habit of selling even more services to its customers and adding new ones to its portfolio. That's a great sign. This dynamic will help Veeva Systems continue growing its revenue, not to mention there is plenty more room for growth in the massive $2.2 trillion life sciences industry.

Veeva Systems set the goal to record $3 billion in annual revenue by 2025. Its expansions into other highly regulated sectors, including chemicals, cosmetics, and consumer packaged goods, present even more opportunities to the company. Leadership in the life sciences industry -- coupled with potentially profitable forays into new markets -- should work wonders for this healthcare company in the coming years.