What happened

Shares of Dollar General (NYSE:DG) gained 16.5% last month, according to data provided by S&P Global Market Intelligence. The stock surged following a stellar second-quarter earnings report, with revenue and earnings beating analysts' expectations.

So what

For the second quarter, net sales increased by 8.4% year over year, driven by strong comp sales growth of 4%. Most impressive was the strength on the bottom line, with adjusted earnings per share up by 14.5%. Speaking to what drove the strong results, CEO Todd Vasos said, "Our results this quarter were fueled by solid execution across many fronts, including category management, merchandise innovation, store operations, and continued progress with our strategic initiatives."

A young woman standing in a store aisle while looking at a grocery item in her hand.

IMAGE SOURCE: GETTY IMAGES.

With the trade war escalating in the last month between the U.S. and China, investors seem to be flocking to those retailers that could be resilient to tariff hikes while avoiding those stores that could be vulnerable. Dollar General has more than 15,000 stores across the country, all delivering value on everyday essentials that customers will still be buying no matter what the broader economy is doing.

Now what

Based on the strong performance in the first half of the year, management raised its full-year outlook. The company now expects sales growth of about 8%, up from the previous expectation of 7%. Same-store sales are expected in the low-single-digit range of about 3%, compared to the previous outlook of 2.5%. This should leave adjusted earnings per share up 8% over 2018, at the low end of guidance.

The company is continuing to invest in certain projects to drive sales growth and margins higher over the long term. These initiatives include shifting to self-distribution of perishable goods to stores, in addition to the integration of digital technology to enhance the in-store experience.

Dollar General has delivered impressive gains for investors this year, up 45% year to date. The stock trades at a forward P/E ratio of 21 times next year's earnings estimate. With this company's management team focused on profitable growth and cost discipline, investors looking for a defensive consumer goods stock should consider Dollar General.