U.S. stocks clung to slim gains in a choppy session on Friday as a stronger dollar and quarterly options expiration unsettled investors before the weekend.

Positive broker comments on Procter & Gamble Co and Chevron Corp helped lift the Dow industrials and shielded the blue-chip average from some of the choppiness.

The U.S. dollar, which has fallen 2 percent so far this month, was having its best day since September 1. The dollar's strength hit commodity prices and weighed on stocks in the materials and industrial sectors.

Quadruple witching -- the expiration and settlement of four different types of September equity futures and options contracts -- added to volatility.

We have been rallying because of dollar weakness, said Peter Boockvar, equity strategist at Miller Tabak & Co in New York. The real test today is: With the dollar bouncing, does that mean the stock market rally will at least moderate?

The Dow Jones industrial average <.DJI> rose 23.05 points, or 0.24 percent, to 9,806.97. The Standard & Poor's 500 Index <.SPX> inched up just 0.40 point, or 0.04 percent, to 1,065.89. The Nasdaq Composite Index <.IXIC> edged up just 0.47 of a point, or 0.02 percent, to 2,127.22.

The S&P 500 is up 58 percent from a 12-year closing low in March, and some investors are looking for a catalyst that might cause stock prices to pull back.

Equity markets seem once again to be priced for everything going completely right and they're highly unlikely to, said Simon Hallett, chief investment officer of Harding Loevner, in Somerville, New Jersey.

The materials and industrial sectors were the worst performers in the S&P 500 <.SPX>. Boeing Co , the aircraft manufacturer and U.S. defense contractor, fell 0.5 percent to $52.63, while Freeport-McMoran Copper & Gold dropped 2.5 percent to $69.66.

Citigroup upgraded Procter & Gamble to buy, saying the consumer products company, which makes Tide detergent and Pampers disposable diapers, is poised to win market share through aggressive pricing, while Credit Suisse upgraded oil producer Chevron to outperform in an otherwise bearish note on major energy companies.

Procter & Gamble's shares rose 3.1 percent to $57.27 while Chevron added 0.8 percent to $72.51. The two ranked among the Dow's top advancers.

Home builders Toll Brothers Inc and KB Home were both upgraded by J.P. Morgan Securities, which said the housing sector will continue to recover over the next 24 months and drive the current rally in home builders' stocks.

Toll shares rose 3.2 percent to $22.22, while KB Home's stock gained 3.4 percent to $20.36. The Dow Jones U.S. Home Construction index <.DJUSHB> jumped 1.2 percent.

On Nasdaq, Palm Inc fell 3.9 percent to $13.89 a day after the company gave a tepid second-quarter sales forecast and said it plans to sell 16 million shares of common stock.

(Editing by Jan Paschal)