The retail drugstores are enjoying a period of time in which many prescription drugs are entering the generic market -- an event known as the "patent cliff." The influx of generics typically spells better margins for the drugstores, which heavily rely on pharmacy sales as a main income driver, as opposed to the lower margin front-of-store items.

The three biggest players -- Walgreen (WBA -0.11%), CVS Caremark (CVS -0.17%), and Rite Aid (RAD 25.83%) -- have all seen their stocks perform well over the past 12 months, with Rite Aid leading the pack by a wide margin. So, looking ahead into the coming years, which drugstore is best for the health of your portfolio?

A good time
All three companies have strong macroeconomic factors weighing in their favor (Obamacare, patent cliff), despite the short-term tepidity in consumer retail spending. Pharmacy sales are rising, the companies are expanding via acquisition, and there are new efforts to increase the profitability of the nondrug sales.

The market has registered this trend, but none of the valuations seem too far out of whack. Walgreen trades at less than 15 times forward earnings, CVS less than 13 times, and Rite Aid, with its near 300% gain in the past 12 months, trades most expensively at 16.93 times forward earnings. At a glance, an investor would be tempted to say Rite Aid has had its fun, and the company, though still in the midst of recovery, is a bit pricey for a retail drugstore. Walgreen is a cheaper pick, and the company is only just starting to reap the benefits of its acquisition of Alliance Boots, the largest drugstore chain in the U.K.

As for the cheapest company at first glance, CVS is set to continue its attractive double-digit earnings growth (net income grew 12% in 2012) on the back of the industry tailwinds. The company's balance sheet, though with $9 billion in long-term debt, appears solidly built. Moody's recently upgraded the company's unsecured rating to Baa1 from Baa2. In its notes, the ratings firm acknowledged industry trends in addition to the burgeoning number of Americans over the age of 65.

Both Walgreen and CVS appear to be relatively low-risk plays on the future of health care in our country. But what about the high-flying Rite Aid?

Expansionists
Just a couple of years ago, Rite Aid was in the proverbial dumpster. During its recovery, sales have yet to make a tremendous comeback, but the company has improved margins substantially. Last year, the company had a negative profit margin that turned back to black in the past four quarters. In its recent guidance, management predicted a 1% margin for the full year.

In such a low-margin business, any sustainable improvement in efficiency goes a long way. Walgreen and CVS have margins above 3%. If Rite Aid continues its margin expansion quest, the bottom line has the potential to grow far, far faster than its peers. Even at a premium valuation to its peers, the company's stock is not overpriced.

All three of the drugstore giants hold their merits as investments in the coming years, and valuation does not keep any from being a good deal today. But the most bang for your buck may come from the fast riser, Rite Aid, which could still go higher yet.