Dollar General (DG -0.41%) stock was trading lower recently after Walmart's latest earnings report. Walmart reported seeing variability in consumer shopping patterns, which could be a warning sign for retailers heading into the all-important holiday quarter.

With Dollar General shares already trading down 52% year to date, investors are wondering if the stock can bounce back. Dollar General might be headed for a weak earnings report on Dec. 7, but there are reasons to believe the stock is oversold.

Inventory shrinkage is a risk in the near term

Retailers are having a difficult time dealing with weak consumer spending trends amid inflation and higher interest rates that are forcing shoppers to cut back. After reporting positive same-store sales in the fiscal first quarter, Dollar General surprised the market with a decline of 0.1% in same-store sales in fiscal Q2. The declining sales trend isn't good news for the stock.

In the last earnings report, Dollar General said it expects continued pressure in sales through the rest of the year. Specifically, its guidance calls for full-year same-store sales to be somewhere between down 1% to up 1% year over year.

The bigger problem for investors is trying to get a read on how much profit the company will earn this year. Retailers are still dealing with excess inventory that could lead to a prolonged period of discounting to move it out the door, and that won't be good for margins.

Dollar General is accelerating inventory reduction, but the company expects this to cut up to $170 million out of operating profit in the second half of 2023. This should translate to a decline between 22% to 34% year over year in earnings per share, per company guidance.

Why buy Dollar General stock?

Dollar General is a solid retail business that has been around forever. With the stock trading at a steep discount, investors have to wonder if the weak sales environment is already priced in.

Before the recent sell-off, the stock was outperforming the broader market, roughly doubling the return of the S&P 500 index for much of the last decade. The economy won't always be in this shape, and this could set up an opportunity to buy a top-tier retail business at a firesale price.

Dollar General also saw weak financials in the 2008 recession before going on to recover and deliver profitable growth that drove the stock higher.

DG EPS Diluted (Quarterly) Chart

DG EPS Diluted (Quarterly) data by YCharts

Dollar General has several things going for it. Management has previously targeted double-digit earnings growth over the long term. One way it seeks to accomplish that is executing a high-return, low-risk acquisition strategy for new store locations.

Despite a store footprint approaching 20,000 stores, it still sees room for expansion and improvement. This year, the company is targeting 990 new stores, 2,000 remodels, and 120 relocations. Most of its new stores and relocations will be larger store formats, which generate higher sales productivity per square foot and will benefit the company when consumers have more spending power.

The low expectations in the near term have sent the stock down to its lowest valuation in over a decade. Dollar General currently sells for just 0.68 times trailing sales, almost half of its average price-to-sales ratio of 1.1 historically.

Warren Buffett has always advocated buying stocks on sale with a big margin of safety. There certainly appears to be one with Dollar General right now. While the stock could hit new lows before it heads higher, it could deliver huge gains off these lows in the years to come. However, investors with a low risk tolerance might want to wait until management offers a stronger sales outlook before buying the stock.