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

The company posted better-than-expected results and raised its full-year sales and profit forecasts, citing inventory management that protected its margins. Shares rose 5 percent.

Chief Executive Terry Lundgren cited the company's My Macy's program which gives stores more leeway to choose merchandise according to local tastes, as well as its focus on exclusive brand lines, as helping.

These factors helped Macy's woo shoppers despite the threat of a new dip in consumer spending that has weighed on rivals like J.C. Penney Co and Dillards . Penney and Kohl's Corp , whose same-store sales gains in July were below Macy's, report their earnings later this week.

Cincinnati-based Macy's reported second-quarter net income of $147 million, or 35 cents a share, compared with $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, compared with Wall Street's average forecast of $1.87.

Macy's shares were up 5 percent at $20.33 on the New York Stock Exchange. Penney shares were down 0.2 percent and Kohl's were down less than 1 percent.

MORE SALES, LEVEL INVENTORY

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; Penney and Dillard's posted declines.

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 got a boost from higher-end spending.

Macy's, which operates about 850 stores under the Macy's and Bloomingdale's names, did not open any stores during the quarter. It plans to open two new Macy's stores, one new Bloomingdale's store and four Bloomingdale's outlets in the second half of fiscal 2010.

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