* Posts earnings 1 cent higher than Wall Street view
* Revenue up 13.3 percent at $30.23 billion
* Sees 2012 earnings of $3.38-$3.41 a share, Street view $3.37
* Shares rise 2.3 percent
Nov 6 (Reuters) - CVS Caremark Corp posted a higher quarterly profit and raised its expectations for the year on Tuesday as it filled more prescriptions with generic medicines and its drugstores held onto former Walgreen patrons.
The company has been working on keeping customers who switched to its stores during an impasse between larger drugstore rival Walgreen Co and pharmacy benefits manager competitor Express Scripts Holding Co.
Walgreen did not fill Express Scripts prescriptions from the beginning of the year until mid-September. This gave CVS and other drugstores the chance to woo Walgreen customers who had to go elsewhere.
CVS expects to retain at least 60 percent of the prescriptions it gained through the fourth quarter, up from its prior goal of keeping at least 50 percent, Chief Executive Officer Larry Merlo said in an interview.
Shares of CVS, which operates the No. 2 U.S. drugstore chain, rose 2.3 percent to $47.70 in premarket trading.
The results came a day after Express Scripts said analysts' forecasts for its 2013 results were too aggressive, casting doubt on how well it is integrating its $29 billion purchase of Medco Health Solutions Inc and sending its shares sharply lower.
CVS has increased its marketing to hold onto new customers who started shopping its stores during the earlier part of 2012, and it will spend more during the fourth quarter to work on retaining them.
The increased marketing spending is already included in the company's outlook, Merlo said.
CVS is raising its fourth-quarter expectations for its pharmacies because it has been keeping more Express Scripts prescriptions, he said. He also cited a rise in flu-related prescriptions and shots, more visits by patients to doctors over the last six months and an increase in Medicare Part D prescriptions.
At the same time, CVS's drugstores and pharmacy benefits units are filling more prescriptions with generic drugs, which are more profitable than brand-name versions.
CVS said it had earned $1.01 billion, or 79 cents per share in the third quarter, up from $868 million, or 65 cents per share, a year earlier.
Excluding intangible asset amortization related to acquisitions, the profit was 85 cents per share. That topped analysts' expectations of 84 cents, according to Thomson Reuters I/B/E/S, and was ahead of the company's forecast of 81 cents to 83 cents.
Revenue rose 13.3 percent to $30.23 billion, beating the analysts' average forecast of $30.09 billion.
Revenue in the pharmacy services business jumped 22.2 percent to $18.1 billion, helped by the addition of new clients, higher drug costs and the growth of its Medicare Part D program for older people.
Revenue at the CVS drugstore chain rose 5.5 percent to $15.5 billion. Sales at stores open a least a year rose 4.3 percent, topping the company's August forecast of a 2.5 percent to 3.5 percent increase.
CVS's same-store sales at the pharmacy counter rose 5.3 percent as Walgreen was not part of the Express Scripts network for the bulk of the quarter.
CVS forecast full-year earnings per share of $3.38 to $3.41, excluding special items. It previously said it had expected $3.32 to $3.38, and the analysts' average estimate is $3.37.