Macy's Inc quarterly results showed the department store operator boosted sales and gained market share without relying as much on discounts as its rivals to get shoppers into stores.

Shares of Macy's rose 5.9 percent after the company posted better-than-expected earnings and raised its full-year sales and profit forecasts, helped by inventory management that protected its margins.

Chief Executive Terry Lundgren said the retailer had gained market share, citing the My Macy's program which gives stores more leeway to choose merchandise by region, as well as its focus on exclusive brand lines.

They've done less discounting. Their gross margins are telling you that either there are fewer promotions, or the promotions that they're running are planned, said Sterne Agee & Leach analyst Ken Stumphauzer.

Macy's was able to woo shoppers despite the threat of a new dip in consumer spending that has weighed on rivals like J.C. Penney Co and Dillards Inc .

Cincinnati-based Macy's said second-quarter net income rose to $147 million, or 35 cents a share, from $7 million, or 2 cents per share, a year earlier.

Analysts on average expected a profit of 29 cents a share, according to Thomson Reuters I/B/E/S. Sales rose 7.2 percent to $5.54 billion, beating Wall Street forecasts of $5.5 billion.

Macy's raised its forecast for full-year same-store sales growth to a range of 4 percent to 4.2 percent. It earlier expected 3.0 percent to 3.5 percent.

The company also raised its full-year profit outlook by 10 cents a share to a range of $1.85 to $1.90 a share, compared with Wall Street's average forecast of $1.87 a share.

Macy's shares closed up $1.14 to $20.52 on the New York Stock Exchange, in a sharply lower stock market. The shares of retailers J.C. Penney and Kohl's Corp fell 0.9 percent and 1.3 percent respectively. Dillard's fell 4.23 percent.

Kohl's and Penney report their earnings later this week.

For a graphic on the three chains' same-stores sales see: http://link.reuters.com/bem54n

GOING LOCAL PAYS OFF

Macy's introduced its My Macy's program in 2008, aiming to reduce the risk of getting stuck with merchandise that shoppers in a given region don't want. It also aims to ensure that its stores don't lose revenue by not stocking the items shoppers are seeking.

They recognized they had a problem with their merchandise mix, said Wendy Liebmann, CEO of consulting firm WSL Strategic Retail. You cannot have a one-size-fits-all mix.

Every month this year, Macy's has reported superior same-store sales results to Penney and analysts said My Macy's had a lot to do with that.

They have a lot of district managers who are closer to the stores, said Stumphauzer. As a consequence, the smaller stores are receiving a lot of attention, and those are the stores in my opinion that historically performed poorly versus Kohl's and versus J.C. Penney.

Macy's operates about 800 namesake stores in the United States and 40 Bloomingdale's stores.

Macy's sales at stores open at least a year rose 4.9 percent, surpassing Wall Street expectations in each of the three months of the quarter.

Last week, Macy's reported a 7.3 percent rise in July same-store sales, while Penney and Dillards posted unexpected declines as they slashed prices to move inventory. Kohl's posted an increase of 4.1 percent.

Merchandise inventories were virtually unchanged from a year ago, helping Macy's gross margins rise 0.4 percentage points to 41.9 percent.

Macy's has redoubled efforts to sell exclusive products, which make up more than 40 percent of sales and offer better margins. Last week, the company launched its Material Girl collection, designed in part by pop star Madonna.

Macy's online sales rose 28 percent and contributed 0.5 percentage points to the same-store sales increase. Its upscale Bloomingdale's chain, which accounts for about 10 percent of sales, got a boost from higher-end spending.

(Reporting by Phil Wahba; Editing by Michele Gershberg, Derek Caney, Lisa Von Ahn, Robert MacMillan, and Carol Bishopric)