The Dow closed at a record on Tuesday, though retreating from the 14,000 mark it earlier crossed for the first time, while the Nasdaq rose to a six-and-a-half-year high on a cascade of stronger-than-expected earnings.

But weakness in energy stocks and lingering worries about the subprime mortgage market held back the advance of the broader S&P 500, which closed virtually unchanged.

A brokerage upgrade of American Express Co. pushed the credit-card company's stock up 4.6 percent and helped lift the Dow average of 30 blue-chip stocks.

Semiconductor stocks gained after Novellus Systems Inc. reported stronger-than-expected results.

Earnings that have come out so far have been supporting the market. There have been no big disappointments, said Subodh Kumar, investment strategist at Subodh Kumar & Associates in Toronto.

The Dow Jones industrial average gained 20.57 points, or 0.15 percent, to end at 13,971.55. The Standard & Poor's 500 Index inched down just 0.15 of a point, or 0.01 percent, to finish at 1,549.37. The Nasdaq Composite Index rose 14.96 points, or 0.55 percent, to close at 2,712.29, after climbing intraday to 2,719.94, its highest in six-and-a-half years.

The Dow set an intraday record high of 14,021.95, crossing 14,000 just under three months since it rose above the 13,000 mark for the first time, and then retreated before the close.

This is a typical bull market in that it is climbing a wall of worry -- there continues to be Iraq, terrorism, inflation and high interest rates, and still the market goes up, said Carl Birkelbach, founder, chairman and CEO of Birkelbach Investment Securities, Inc., in Chicago.

In trading after the closing bell, shares of Internet media company Yahoo fell 1.9 percent to $27 after it reported a dip in quarterly profit in line with previously lowered expectations. Intel, the largest maker of computer processors, dropped nearly 5 percent to $25.05 in extended-hours trading after it posted a rise in second-quarter earnings, but missed its gross margin goal.

EXXON AND MERRILL LYNCH DEFLATE

In regular trading, energy stocks fell, led by Exxon Mobil on concern about dwindling profit margins for gasoline. Exxon shares slipped 0.7 percent to $89.09.

Worries about the subprime mortgage market also continued to rumble.

Merrill Lynch & Co. was among companies that posted earnings that exceeded estimates, but its stock erased early gains after its chief financial officer said in a conference call that the market for subprime collateralized debt has yet to stabilize. Its shares slipped 1.4 percent to $86.20.

MONEY MACHINES IN HIGH GEAR

Other financial companies whose earnings topped forecasts were State Street Corp., Jefferies, and KeyCorp. The gains helped push the S&P financial index up 0.5 percent.

Shares of State Street, the world's biggest institutional money manager, added 2.1 percent to $71.87. Jefferies shares rose 3.6 percent to $29.75, while KeyCorp gained 4.6 percent to $36.71.

The S&P materials index gained 0.6 percent, after paint and coatings makers Rohm and Haas Co. said late on Monday its board of directors authorized the repurchase of up to $2 billion of its common shares. Rohm shares shot up 9.9 percent to $61.27.

American Express stock rose 4.6 percent to $64.74 following an upgrade by Goldman Sachs, which said American Express' network business was undervalued by the market.

Takeover activity also helped stocks. Lyondell Chemical shares surged 17.3 percent to $47.05 and ranked near the top of the Big Board's list of biggest percentage gainers after chemical maker Basell said it would buy the company for $48 a share in an all-cash deal.

Trading was moderate on the NYSE, with about 1.44 billion shares changing hands, below last year's estimated daily average of 1.84 billion.

On the Nasdaq, about 2.22 billion shares traded, above last year's daily average of 2.02 billion.

Declining stocks outnumbered advancing ones by a ratio of about 19 to 14 on the NYSE, while advancers slightly outnumbered decliners on Nasdaq.