The thought of generic drugs may keep big pharma companies up at night, but pharmacies such as Rite Aid (RAD), CVS Caremark (CVS -0.57%), and Walgreen (WBA -3.08%) love 'em.

That's because pharmacies' margins on generic drugs is better than on branded drugs. Significantly better. According to a 2012 study conducted for the Centers for Medicare and Medicaid Services, the typical pharmacy makes a gross profit of roughly 10% when it fills a brand prescription, and almost 50% when it fills a generic prescription.

Given that generics account for nearly 80% of all prescriptions,up from 64%at the end of 2009 and 48% in 2003, Rite Aid and its peers are uniquely positioned for profit growth as more than $123 billion in branded drug sales lose patent exclusivity between 2012 and 2017. That steep drop-off, commonly called the patent cliff, is one reason that industry tracker IMS predicts generics' global share of drug spending will grow from 27% to 36% during the period.

If that estimate proves correct, Rite Aid's earnings should head higher as the generic margin more than offsets top-line headwinds tied to generics' lower prices. 

RAD Chart

RAD data by YCharts.

First, a bit of background
Rite Aid is the third-largest pharmacy chain in the country, operating more than 4,500 stores, primarily on the East and West coasts. Overall, Rite Aid filled more than 297 million prescriptions in 2013.  

Thanks to new stores and acquisitions, Rite Aid, CVS, and Walgreen collectively control nearly 45% of the pharmacy script market, while independents' share totals just 16%. That dominant market share positions the chains perfectly as an average of 10,000 baby boomers turn 65 each day.

The over-65 population is expected to double between 2010 and 2030. Since the number of prescriptions taken per year increases with age (the average number of scripts filled annually for those over 65 is double that of those under 55), prescriptions filled at Rite Aid and its peers are likely to grow significantly in the coming decade. That's good news for profit growth given that prescriptions already make up two-thirds of Rite Aid's total sales.

Margin and share price
Although revenue growth is important, the biggest driver of share price for most companies remains earnings growth. Unless you're operating a new, disruptive business, investors are usually not willing to continue overpaying for shares in companies with falling earnings.

That dynamic is particularly true in retail, and it has been especially true for Rite Aid. Following its $2 billion acquisition of the Eckerd chain in 2007, the company's share price cratered to less than a $1 in 2010 as earnings turned into losses.

But that was then, and this is now.

Rite Aid's share price has quadrupled in the past year as a debt restructuring, store closures, a focus on health services like immunizations, and generic drug launches rejuvenated the bottom line. The company is leaner and stronger than it has been in years, making it far more able to focus attention on reversing its also-ran status.

The timing couldn't be better. CVS and Walgreen will remain the dominant players, but they'll no longer be the only pharmacies with the firepower to expand into prescription-friendly retail clinics and patient-centric counseling, which boosts customer adherence and script counts.

Those investments should have additional margin-friendly consequences for Rite Aid given that the industry is already enjoying a margin bounce thanks to patent expiration for top-selling drugs --notably Pfizer's megablockbuster Lipitor at the end of 2011. In total, $55 billion in branded drug sales lost patent protection in 2012, marking a low in industry operating margin.

CVS Operating Margin (TTM) Chart

CVS Operating Margin (TTM) data by YCharts.

Fool-worthy final thoughts
The biggest tick higher in pharmacy margin occurs in the first six months following a generic launch. That suggests that a pop in patent expiration from $28 billion last year, to $34 billion this year, and to $66 billion in 2015, should provide plenty of profit opportunity for Rite Aid, CVS, and Walgreen. That has industry analysts projecting that earnings per share for the three companies will head higher through 2015.

Of the three, hope is highest for Rite Aid. Analysts expect Rite Aid will grow its EPS by 28% year over year in 2015, versus 12.8% for CVS and 13.3% for Walgreen. That suggests that generic drugs will lend a significant helping hand for these companies, and their share prices, through next year.