Discount retailer Dollar General (DG) - Get Report beat earnings estimates in the first quarter as gross margins increased.

The Goodlettsville, Tenn. company, which operates 12,483 stores in 43 states, posted diluted earnings per share of $1.03, a rise of 23% year on year and well above a consensus forecast for earnings per share of 95 cents.

Revenue rose 7% to $5.27 billion, just under analysts' prediction for sales of $5.28 billion. Same-store sales rose 2.2%, whereas Wall Street had been looking for growth of 2.4%.

"We remained keenly focused on ensuring the effectiveness and efficiency of every aspect of our business as we delivered both gross margin expansion and selling, general and administrative expense leverage," said CEO Todd Vasos in a statement. "This balanced performance contributed to operating profit improvement of 12% and diluted earnings per share growth of 23%. We are confident in our opportunities for growth and remain committed to creating sustainable long-term shareholder value."

Gross margins came in at 30.6%, which Dollar General said was a year-on-year improvement of 16 basis points, partly because of lower transportation costs. Its $295 million of first-quarter net profit compared with $253 million in the first quarter of last year.

Last year, Dollar General reported earnings of 84 cents per diluted share on revenue of $4.92 billion.

Dollar General closed in New York on Wednesday up 71 cents at $81.43.

TheStreet's Jim Cramer, co-manager of the Action Alerts PLUS portfolio, said Wednesday from the floor of the New York Stock Exchange, that he liked both Dollar Tree (DLTR) - Get Report and Dollar General, though preferred Dollar Tree to its rival, which he described as "steady as she goes."

Dollar General said it has authorization to buy back another $693 million of shares after share buybacks and dividend payouts amounted to more than $300 million in the first quarter.