CVS Health Corporation (CVS 1.15%) took a few hits in 2016 from its major nemesis, Walgreens Boots Alliance (WBA -0.23%). Prime Therapeutics and Tricare kicked CVS to the curb in favor of Walgreens. As a result, CVS Health was forced to lower its financial outlook.

It's no surprise that Walgreens stock has handily outperformed CVS over the past 12 months. But which pharmacy company is the better pick for investors with a long-term perspective? Here's how CVS Health and Walgreens compare.

A pharmacist holds a pill bottle as he keys information into a computer.

Image source: Getty Images.

The case for CVS Health

There are four key arguments for buying CVS Health, in my view. At the top of the list is the company's pharmacy benefits management (PBM) unit. This segment generated more than two-thirds of CVS Health's total revenue last year. It's the company's fastest-growing unit in terms of both revenue and profit. Having a PBM also gives CVS Health a wider reach across the healthcare spectrum than its competitors have.

CVS Health is also in a great position to benefit from the increased numbers of senior adults in the United States. As Americans age, they tend to need more prescription drugs. That will help CVS, but it will also benefit its rivals. However, CVS Health's 2015 acquisition of Omnicare gives the company an advantage in the long-term and post-acute care market, which should grow thanks to the demographic trends.

Next on the list is CVS Health's dividend. The dividend yield currently stands at 2.62%. Even better, CVS is using only 37% of earnings to fund the dividend program. That leaves plenty of room for dividend increases in the future.

The last key argument for buying the stock is its valuation. Those contract losses to Walgreens caused CVS Health's share price to take a beating. As a result, the stock now trades at a low 12 times expected earnings. With the company projecting 10% adjusted earnings-per-share growth over the long term and the solid dividend, that's a quite attractive valuation.

The case for Walgreens Boots Alliance

I think there are also four major reasons for investors to like Walgreens Boots Alliance. Let's start with an advantage that the company has over CVS Health: a strong international presence -- thanks to the merger between Walgreens and Alliance Boots in 2014. The company's international sales totaled $13.3 billion last year. Walgreens Boots Alliance is also one of the largest pharmaceutical wholesalers and distributors in Europe. The pharmaceutical wholesale segment contributed $22.6 billion in revenue last year.

It's also not insignificant that Walgreens is beating CVS Health in winning new business. Taking Tricare away from its rival added 9.4 million members. Getting the Prime Therapeutics contract brought in even more members -- 22 million. These wins certainly give the impression that Walgreens is simply outworking its competition. That's something investors like to see.

This relates to the third key argument for Walgreens: its growth prospects. Wall Street analysts are projecting nearly 14% average annual earnings growth over the next few years. And that doesn't include the possibility that the company will succeed in its effort to buy Rite Aid (RAD 5.26%).

The potential Rite Aid acquisition has played out like a pharmacy-chain soap opera over the past year. Speculation has ebbed and waned as to whether or not the deal will ultimately gain approval from the U.S. Federal Trade Commission (FTC). It still remains to be seen if the FTC gives its blessing to the acquisition, but if it goes through, Walgreens will mushroom in size.

Finally, Walgreens' valuation looks appealing. Walgreens stock trades at nearly 15 times expected earnings. That's higher than CVS Health's forward earnings multiple. However, factoring in growth prospects for the two companies makes Walgreens' valuation look even more attractive than CVS Health's.

Better buy

I think Walgreens gets the slight nod over CVS Health. Growth is the determining factor, in my view. Walgreens should experience stronger earnings growth, even if the Rite Aid deal falls through. 

However, I also suspect that both of these companies need to be looking over their shoulders. is seriously eyeing the pharmacy market. Although it would probably take years for the e-commerce giant to significantly cut into profits for CVS and Walgreens, the companies would be wise to prepare now for a potential new competitor.