There were probably plenty of smiles in Camp Hill, Pa., today. 

Big pharmacy chain Rite Aid (RAD 24.00%), which is headquartered there, announced superb results from its second quarter. Smiles likely also lit up the faces of shareholders across the country as the stock soared more than 23%. 

Rocking numbers
Rite Aid reported revenue for the second quarter of $6.3 billion -- up from $6.2 billion in the same period for 2012. That 0.8% improvement came despite store closures since last year and was driven largely by a 1.7% increase in same-store pharmacy sales. Analysts expected a top-line number of $6.27 billion.

The bottom line presented a very pleasant surprise. Rite Aid's net income came in at  $32.8 million or $0.03 per diluted share. That's a significant improvement from last year's second quarter loss of $38.8 million or $0.05 per diluted share. It's also much better than the $0.04-per-share loss projected by Wall Street.

John Standley, Rite Aid's Chairman and CEO, noted that adjusted EBITDA of $341.6 million for the quarter set an all-time record for the company. That figure represented 5.4% of total revenue.

What accounted for the strong quarterly results? Introduction of more generic drugs played a major role. While lower-cost generics can put a damper on total revenue, they provide a nice boost to gross margins. 

Rite Aid also did a good job of controlling costs. Selling, general, and administrative expenses -- the biggest line item cost -- fell from almost $1.62 billion in the second quarter of 2012 to a little more than $1.6 billion in the last quarter. 

Rolling ahead
The rest of the 2014 fiscal year looks to be pretty good for Rite Aid. The chain raised its full-year sales guidance to between $25.1 billion and $25.3 billion. Earnings guidance was also upped, with full-year estimates between $182.0 million, or $0.18 per diluted share, and $268.0 million, or $0.27 per diluted share. Adjusted EBITDA is anticipated to be between $1.240 billion and $1.300 billion.

If you had said in January that Rite Aid would beat its major rivals in stock performance by more than fourfold, some would have likely laughed. Rite Aid shareholders now appear to be getting the last laugh. Shares have shot up more than 230% this year. Meanwhile, key competitors CVS Caremark (CVS -1.07%) and Walgreen (WBA -1.33%) are up 23% and 51%, respectively.

Rite Aid remains a distant third to the other chains in other key metrics, though. CVS and Walgreen still generate much higher revenue and claimed higher profit margins over the last 12 months. 

The tremendous stock move this year also could also be viewed as making Rite Aid the priciest of the three pharmacy retailers. The company's forward price-to-earnings ratio stands higher than the multiples of both CVS and Walgreen. 

However, Standley is probably more focused on what his company must do internally rather than how it compares to competitors. He cited "tremendous progress in transforming our more than 4,600 stores into true neighborhood destinations for health and wellness" as a major accomplishment behind the company's success in 2013. Standley also highlighted Rite Aid's ongoing store remodeling effort, which extended to its 1,000th store during the last quarter.

Rite Aid has already surpassed the price target for even the most optimistic analyst. It's possible that the market could become overly exuberant, resulting in a pullback in the near term. However, from an operational standpoint, this pharmacy chain certainly appears to be on the right track to roll full steam ahead.