Today's battle features a convergence of two of the most promising industries of the past decade: healthcare and software as a service (SaaS). Veeva Systems (VEEV -0.71%) offers cloud solutions for Big Pharma to track customer relationships as well as mission-critical test data. Athenahealth (ATHN) is building out a cloud-based record of patient information.

But their recent returns haven't quite been the same. Veeva's stock has tripled since mid-2014, while Athena's remains almost exactly where it was over three years ago. That might make one believe that Athena would be a better stock to buy now -- but is that the case?

A doctor entering information into a tablet

Image source: Getty Images.

There's no way to answer that question with 100% certainty. But there are a number of different ways to approach the question that can help give us a better idea of what we're buying when we purchase shares of either company.

Sustainable competitive advantage

When it comes to long-term, buy-to-hold investing, nothing is more important to investigate than the sustainable competitive advantage -- or "moat" -- of the underlying company you are putting your money behind.

In the simplest sense, a moat is what separates your company from all of the competition, promising that customers will come back week after week while holding the competition at bay for decades. Those factors create compounding that produces dynastic wealth for shareholders.

Veeva's key moat is provided by high switching costs. Big pharmaceutical companies that have all of their customer data stored on Veeva CRM and -- more importantly -- all of their clinical and regulatory data stored on Veeva Vault will think twice before ever switching away. That's because the costs of migrating all of that data -- in terms of money, time lost, headaches, retraining, and the potential for losing key information -- would be monumental. As Veeva adds ever more tools to its cloud offerings, customers become even more locked in for the long-haul.

Athena got its start by providing a platform that small health agencies could use to store and share patient data. That provides two big moats: the aforementioned high switching costs that Veeva enjoys, and also the network effect. As more and more health agencies start using the AthenaOne Network, non-users are incentivized to join as it gives them easy access to customer data they might not otherwise have.

In the end, though, I'm going to give Veeva a slight advantage here. That's because Athena is going up against some very big players -- it's trying to steal market share away from companies that provide software for larger enterprise healthcare organizations. The network effect is not providing the type of boost one would expect, while Veeva continues to win over customers.

Winner = Veeva

Financial fortitude

Investors in these companies have no fantasies about receiving dividends. Most of the cash the companies bring in is being reinvested in growth opportunities.

But there's something to be said for keeping a reliable war chest on hand. Every company eventually faces difficult economic circumstances. When that happens, those that have lots of cash -- and not too much debt -- can actually come out stronger. They can buy back shares on the cheap, acquire rivals, or -- most importantly -- outspend rivals to gain long-term market share.

Keeping in mind that Veeva is valued at roughly 170% the size of Athena, here's how the two stack up.

Company

Cash

Debt

Net Income

Free Cash Flow

Veeva

$725 million

$0

$117 million

$212 million

Athenahealth

$311 million

$258 million

$31 million

$44 million

Data source: Yahoo! Finance. Net income and free cash flow presented on trailing twelve-month basis.

Both companies have relatively stable balance sheets, but the advantage here goes once again to Veeva. With no debt to speak of and free cash flow that is far stronger than Athena's, I believe Veeva would be more likely to gain strength in an economic downturn as a result of some type of financial trouble.

Winner = Veeva

Valuation

Finally we have valuation, which is part art and part science. There's no one metric that lets you know if the stock you are buying is cheap or expensive, so I like to look at a number of different metrics to get a more comprehensive perspective. Here are three of my favorites.

Company

P/E

P/FCF

PEG Ratio

Veeva

68

40

3.1

Athenahealth

162

114

3.2

Data source: Yahoo! Finance, E*Trade. P/E presented using non-GAAP EPS.

By traditional metrics, they are undoubtedly expensive -- but it appears that Veeva has the advantage once again.

My winner is...

So there you have it: Veeva appears to be a better buy today, based both on the fact that its moat is wider and that it has a more solid balance sheet. And I've backed that assertion up -- I'm a shareholder of Veeva, which accounts for over 3% of my real-life holdings.