Dollar General Corp posted bigger-than-expected gains in quarterly sales and profit and raised the low end of its full-year forecast on Tuesday, as shoppers visited its discount stores more often to buy food and other basic items.

Shares of Dollar General, which is carefully balancing demand for low-priced goods with manufacturers' push to raise prices, rose 2.8 percent to $34.75 in premarket trading.

I saw a lot of encouraging signs in the results, said BB&T Capital Markets analyst Anthony Chukumba. He called the second quarter a great rebound from the rare shortfall the company posted for the first quarter.

Sales at stores open at least a year, or same-store sales, rose 5.9 percent, a faster clip than the first quarter's 5.4 percent rise.

Meanwhile, the gross margin decline was much narrower than in the first quarter, admirable given the higher commodity and fuel costs the company faces, he said.

Dollar General's customers are buying an increasing proportion of lower-margin necessities as they cut back on discretionary purchases due to higher gas prices, continued high levels of unemployment and other economic concerns.

Sales of items such as candy, snacks and other food continued to increase at a higher rate than merchandise such as home, apparel and seasonal goods during the quarter.

For Dollar General, which prices most of its merchandise below $10, the weak economy is a double-edged sword. As lower-income shoppers seek low-priced food and other basic goods, a soft economy brings new customers into its stores and those of competitors such as Family Dollar Stores Inc .

The second half of this year is setting up quite nicely for Dollar General, said BB&T's Chukumba, who has a buy rating on Dollar General and a hold rating on Family Dollar.

The U.S. macroeconomic environment remains challenging, so we should see a continuation of the trade down phenomenon where consumers are trading down to Dollar General from higher-priced alternatives such as supermarkets, convenience stores and drugstores, he said.

PROFIT UP

Dollar General, which has more than 9,640 stores, more than any other chain in the United States, said sales rose 11.2 percent to $3.58 billion, above the $3.54 billion analysts were expecting according to Thomson Reuters I/B/E/S.

The retailer earned $146 million, or 42 cents per share, in the fiscal second quarter that ended on July 29, up from $141 million, or 41 cents per share, a year earlier.

Earnings of 52 cents per share, excluding items, exceeded analysts' average forecast of 48 cents.

Shoppers buying more food and basic goods rather than discretionary items pressures profitability, as those items generally carry a lower gross profit rate than other goods. At the same time, the prices Dollar General paid for goods rose due to higher commodity and fuel costs.

Gross profit dipped to 32.1 percent of sales from 32.2 percent of sales a year earlier. Over the first six months of the year, gross profit fell to 31.8 percent from 32.2 percent.

Dollar General now expects to earn $2.22 to $2.30 per share for its 53-week fiscal year, versus a prior forecast of $2.20 to $2.30 per share.

It expects sales to rise 12 percent to 14 percent, up from a prior forecast of 11 percent to 13 percent. Same-store sales are now expected to increase by 4 percent to 6 percent, versus an earlier forecast of 3 percent to 5 percent.

Dollar General is majority-owned by private equity firm Kohlberg Kravis Roberts & Co LP , which brought the Goodlettsville, Tennessee-based company back to the public market in November 2009.

(Reporting by Jessica Wohl; editing by Jeffrey Benkoe, Dave Zimmerman)