Dollar General (DG -0.59%) and Tractor Supply (TSCO 2.20%) have outperformed many of their retailing peers over the past year. Sales trends held up well despite slowing economic growth, and profit margins remained strong.

Investors have rewarded that success by pushing these stocks higher compared to the S&P 500's gains. But which one is the more attractive purchase right now? Let's dive right in.

The latest results

While both companies are winning market share, Tractor Supply comes out ahead on growth. Sales jumped 21% in the most recent quarter and were up 12% for the full 2022 year. This surge was driven by a combination of rising traffic, higher spending, and an expanding store base. The rural lifestyle retailer's fourth-quarter results beat management's targets, giving it solid momentum heading into fiscal 2023.

Dollar General is on pace to grow comparable-store sales at a roughly 4% rate for the full 2022 year, management said in a preliminary Q4 announcement. Executives said this surprisingly weak result was mostly due to the impact of a major winter storm across much of its store base.

But Dollar General may also be facing a tougher challenge in convincing shoppers to spend freely as inflation raises prices. Give Tractor Supply additional growth points because management is projecting another year of market-beating growth ahead in 2023.

Earnings and cash flow

Tractor Supply wins the matchup with respect to profitability, too. The company has had no trouble passing along price increases and shifting its merchandising strategy away from weaker areas like home furnishings. This success has allowed the operating margin to hold steady at 10% of sales even as larger retailer, Target, saw its comparable figure fall to 4% of sales last year from 8% a year earlier.

In contrast, in Dollar General's third-quarter announcement, executives cited cost pressures and supply chain challenges, which pushed operating income down to 8% of sales. Management is aiming for a rebound in fiscal 2023, but the company has still taken a step backward here while Tractor Supply maintained the positive momentum that investors saw though earlier phases of the pandemic.

Outlook and valuation

As you might expect, the retailers have been assigned different valuations that reflect their varying performances. You have to pay about 1.8 times annual sales for Tractor Supply today compared to 1.3 for Dollar General. Slower-growing retailers, including Walmart, are valued at less than half that multiple.

But Tractor Supply has earned that premium by consistently winning market share and protecting profitability through a challenging selling environment. Dollar General might appeal to investors seeking less risk. Besides the stock's lower valuation, the company has a much larger national store base, with annual revenue of $36 billion compared to Tractor Supply's $15 billion. Dollar General sells a higher proportion of consumer staples, too, which may cushion its sales trends in the event of a recession.

But Tractor Supply stock will appeal more to growth-focused investors. The retailer has room to boost spending at existing locations even as it adds to its store base and builds out its e-commerce infrastructure. Its double-digit operating margin is extremely rare to see in the retailing industry, too. Successes like that are likely to power more market-beating returns for investors willing to hold this stock over the long term.