The S&P 500 remains slightly in the red over the past year, but zooming out helps put things in perspective. Over the past five years, the index has delivered solid returns, and so have the corporations that were dragged down in 2022's downturn. And even more importantly, some of these companies can still provide excellent performances over the long run for patient investors.

Veeva Systems (VEEV 0.17%) and Etsy (ETSY 1.56%) are two such examples. Let's dig in.

VEEV Chart

VEEV data by YCharts

1. Veeva Systems

Veeva Systems offers cloud-based software solutions to life science companies. Its industry-specific platform has allowed it to become popular among those within its target market. That's why some of the largest drugmakers use Veeva's software, from Vertex Pharmaceuticals to Merck, in addition to many others.

This popularity has generally led to solid financial results. The company's fiscal 2023 ended on Jan. 31. During this period, it reported revenue of $2.2 billion, an increase of 16% compared to the prior year. Veeva's adjusted earnings came in at $4.28 per share, up 14.7% compared to the previous fiscal year.

The past five years' worth of results shows similar progress for Veeva Systems' top and bottom lines. 

VEEV Revenue (Quarterly) Chart

VEEV Revenue (Quarterly) data by YCharts

There are good reasons to believe the company can continue down that path. Veeva Systems set a goal to generate $3 billion in revenue by 2025. It has generally achieved its top-line targets ahead of time. But even beyond the next couple of years, it's worth noting that the industry it targets with its software solutions is worth $2 trillion and growing.

The company's goal is to make headway within this massive market by launching new, specialized cloud solutions that cater to the needs of its target market while growing the adoption of various services it offers its existing users. Veeva's retention rates for its subscription services typically come in well above 100%, meaning it is in the habit of adding new clients to its portfolio.

Furthermore, Veeva benefits from high switching costs. Migrating to another cloud provider can be costly and time consuming. Plus, it carries the risk of losing valuable data and potentially interrupting business. That can be catastrophic for companies in a highly regulated field like the healthcare industry. This factor grants Veeva Systems a competitive advantage.

Finally, the company has started branching out into other highly regulated sectors, most notably consumer goods and chemicals. Veeva estimates a more than $13 billion total addressable market. That's why there remains plenty of fuel in Veeva Systems' growth engine, making the stock a buy for long-term investors. 

2. Etsy 

Etsy is an e-commerce company that has also found success by focusing on a specific niche of this vast and highly competitive industry. It sells handmade, vintage, and unique goods. That isn't all one can find on this platform, but Etsy is known primarily for these types of items. This reputation is one of its strengths. The company connects merchants of these specialized goods with consumers, resulting in a flywheel effect. 

According to Etsy's surveys, 87% of buyers on its platform say it has items one can't find anywhere else, and 71% agree with the claim that there is no other e-commerce hub like Etsy. Word of mouth remains one of the best methods of advertisement. And with its customers impressed with the company's collection of rare goods, they will spread the word when family members or friends are looking for similar products. 

This dynamic has been critical to Etsy's success over the past few years. The company saw its business slow down in 2022, but contextualizing things is important. Etsy experienced an abnormal boom during the pandemic. It made a small fortune on sales of handmade masks, but even beyond that, a lot of retail activity moved online during the first two years (or so) of the outbreak, so many e-commerce companies benefited. 

Now that this tailwind is over, things are returning to normal for Etsy, and last year it had to deal with difficult year-over-year comparisons. Its revenue in 2022 increased by 10% to $2.6 billion, a lower growth rate than what investors are used to. Furthermore, Etsy's net income of $493.5 million in 2021 turned into a net loss of $694.3 million in 2022. Its active sellers and buyers dropped slightly as well.

With that said, pandemic-related dynamics will eventually cease to impact Etsy's results. And given the vast opportunity in e-commerce -- it accounted for just 14.7% of retail sales in the U.S. in the fourth quarter -- the company's revenue and earnings will move in the right direction for a long time once it puts these recent issues in the rearview mirror.

Etsy estimates it has a total addressable market of $2 trillion, meaning it has barely started to scratch the surface. The company won't capture this entire opportunity by itself, but as a leader in its niche, it should grab a decent portion of it. Even 10% would substantially improve its revenue and earnings over their 2022 levels. With this much potential, Etsy can continue beating the market for years.