The consumer price index rose 8.3% year over year in August, levels the country hasn't seen in four decades until now. The average American household is spending several thousand more dollars each year, forcing many consumers to modify their spending habits.

Dollar General (DG -0.36%) could end up benefitting from the swift change in consumer spending habits. It could also benefit from its status as a value stock, which investors tend to flock to during economic turmoil. But is the stock a buy for those seeking a stable investment? Let's check out the dollar store company's operating results and valuation to try to get an answer.

Dollar General is seeing healthy revenue and earnings growth

With a $54 billion market capitalization and more than 18,000 stores in 47 U.S. states, Dollar General is the largest retailer in the U.S. by store count. This large store count uniquely positioned the company to benefit from a shift in consumer spending last quarter toward more discount merchandise. Dollar General reported $9.4 billion in net sales during the quarter, which was up 9% over the year-ago period.

What factors were behind this robust net sales growth? It's important to understand that high inflation and less discretionary income left many consumers less interested in more expensive items, such as electronics. These same consumers are more interested in necessary items, including common household products and food. 

And thanks to Dollar General's presence in historically underserved communities, such as small and rural towns, the company is meeting this increase in demand for its products. Due to the company's outsize store count, roughly 75% of the U.S. population lives within five miles of a Dollar General store.

The change in consumer spending habits and the growing reach of the company's stores help explain how Dollar General's same-store sales increased by 4.6% year over year for the second quarter. Along with a 5% increase in the store count over the year-ago period, this is how the company's net sales grew at such a fast clip for its size.

Dollar General generated $2.98 in diluted earnings per share (EPS) in the second quarter, which was 10.8% higher year over year. The company's higher net sales base was somewhat offset by a 20-basis-point decline in its net margin to 7.2% during the quarter. But a 3.8% reduction in Dollar General's outstanding diluted share count to 227.5 million via share repurchases neutralized the lower profitability. This explains how diluted EPS grew at a faster rate than net sales for the second quarter.

As Dollar General continues to open more stores in new communities and repurchase shares, analysts anticipate that the company's diluted EPS will grow 11.4% annually through the next five years.

A person shops for groceries.

Image source: Getty Images.

Dollar General has a well-covered dividend

Given that the average stock in the S&P 500 index has a dividend yield of 1.7%, Dollar General's 0.9% yield admittedly isn't going to entice investors looking for immediate income. But for those with time on their side, the company's dividend has real potential to rapidly compound in the years ahead.

Part of the reason is Dollar General's dividend payout ratio is currently a mere 19%. That's more than enough capital for the company to open new stores, repay debt, further reduce its share count, and raise its dividend. It's why I believe that dividend growth will be higher than earnings growth for the foreseeable future, allowing for double-digit annual dividend hikes moving forward.

Dollar General stock is slightly discounted

Dollar General is a strongly positioned and growing business. And the valuation appears to be about as compelling as the value proposition that the company's products present to its bargain shoppers.

This is because Dollar General's Shiller price-to-earnings (P/E) ratio of 34.2 is a bit lower than its 10-year median Shiller P/E ratio of 37.4. The Shiller P/E ratio accounts for the cyclicality of corporate earnings over a period of 10 years, which is often thought to represent a full business cycle. Since Dollar General's fundamentals appear to be more solid now than at any other time in the last decade, I would argue that this makes the stock a convincing buy to help investors build wealth