Recently Dollar General (DG -0.36%) soared 6.1% on news that it handily beat analyst expectations for the quarter. As a result of this share price increase, the company touched a new 52-week high. With this news, though, is Dollar General overvalued or does the company still have some room to run especially as competition from Family Dollar Stores (FDO.DL) and Dollar Tree Stores (DLTR -0.57%) heightens?

Earnings crushed the forecast but revenue fell short
For the quarter, Dollar General reported earnings per share of $0.74. This represents a 19.4% improvement from the $0.62 that the company reported for the same quarter a year earlier and a 5.7% increase over the $0.70 that analysts expected. Looking at the company's earnings release, you can see the increase in the company's bottom line stemmed from a number of factors.

First, revenue rose by 10.5% from $3.96 billion to $4.38 billion. Unfortunately, Dollar General fell short of the $4.42 billion in revenue that analysts expected but the increase was attractive nevertheless. This growth, in turn, stemmed from a 6.7% increase in the number of stores in operation, combined with a 4.4% increase in comparable-store sales.

Second, shareholders benefited from a 3.4% decrease in the number of shares outstanding compared to the same period a year ago. The decrease came about because of share buybacks. In fact, over the quarter the company bought and retired $200 million worth of shares and increased its capacity for buying stock to $1 billion.

Finally, the company did see some minor improvements in terms of margins. For the quarter, its net profit margin increased from 5.24% to 5.42%. This change took place as slight cost reductions were realized and was partially offset by a slight increase in the company's cost of goods sold.

(DLTR -0.57%)

From fiscal 2009 through 2013, revenue at Dollar General rose by 53.2% from $10.5 billion to $16 billion. This outpaces the 40.4% growth experienced by Family Dollar. On the other hand, this revenue growth falls short of the growth chalked up by Dollar Tree. Over the same time horizon Dollar Tree, the smallest of the three, grew revenue by 59.2%.

On a net income basis, Dollar General has seen tremendous growth. From 2009 through 2013, the company's bottom line rose by 780.5% from $108.2 million to $952.7 million. The company's net profit margin has expanded annually, rising from 1% in 2009 to 5.9% in 2013.

In juxtaposition, Family Dollar's net profit margin has stagnated in spite of a 52.3% jump in net income. Between 2009 and 2013, Family Dollar's net profit margin hovered around 3.9%-4.6%. Like Dollar General, Dollar Tree has seen nice upticks in both its net income and net profit margin on an annual basis. Over the same time-frame, Dollar Tree's net income rose by 169.8% from $229.5 million to $619.3 million while its net profit margin increased from 4.9% to 8.4%.

The reason for the difference between Family Dollar and its competitors is attributed to Family Dollar's inability to control costs. This is best shown by looking at each company's cost of goods sold and selling, general, and administrative expenses as a percentage of sales. While both Dollar Tree and Dollar General saw these metrics improve over the past five years, Family Dollar has been hit with a higher cost of goods sold relative to its revenue.

Foolish takeaway
Between reporting blowout earnings this quarter and exhibiting high growth and margin improvement over the past few years, it's not difficult to see that Dollar General is an attractive company. From a growth and margin perspective, Dollar General is far more interesting than Family Dollar. However, there are two problems with Dollar General. The first comes down to the amazing competition the company faces at the hands of Dollar Tree. Though Dollar Tree's net income hasn't grown at the same pace as Dollar General, the company clearly beats out Dollar General when it comes to revenue growth and margins.

The other problem comes down to cost. Right now, Dollar General trades at 19.9 times earnings, making the stock fairly expensive relative to Dollar Tree, which is growing earnings at a faster clip.