The stock market, after days of drifting aimlessly, yesterday staged a final-hour rally that carried the Dow Jones industrial average up nearly 18 points to an all-time high of 1,368.50.

The new record eclipsed the previous Dow Jones high of 1,359.54, set July 19. The Dow added 17.69 points yesterday.

Volume on the New York Stock Exchange increased to 117.36 million shares from 110.35 million Tuesday.

Twenty-two percent of yesterday's volume -- 25.3 million shares -- came in the last hour.

Activity in takeover stocks, short covering, expectations of improved economic news and Federal Reserve Chairman Paul Volcker's reassurance he would stay on the job were credited by analysts with helping to move the market.

But the analysts expressed doubt about the durability of the rally.

Michael Metz, market strategist at Oppenheimer & Co., said the market appeared to be "in a mini-stampede phase for the next few days," but said he looked for "a protracted period of erosion" afterwards.

The market, he said, would lag because it had neither the improved business earnings nor the lower interest rates needed to provide momentum for a sustained rally.

Hildegarde M. Zagorski, market strategist at Prudential Bache, said of the rally, "I don't think it has too far to go on the upside before it comes tumbling down."

Zagorski said that the ratio of 965 advancing stocks to 534 declining issues did not reflect a a true bullish move. "It should be 3 to 1 on the upside," she said.

Zagorski noted that while the closely watched DJ industrial average hit a new high, most other broad market measures were well below their record levels, thus failing, she said, to confirm the Dow's direction.

Market watchers said traders covered short positions in blue chips when the Dow broke the old high. This, in turn, helped send the DJ industrial average, composed of blue chip stocks, even higher.

After the market closed, Commerce Secretary Malcolm Baldrige said he expects third-quarter gross national product growth will be revised upward from the flash estimate of 2.8 percent.

The third-quarter GNP figure is due out this morning.

The government said yesterday that industrial production dropped 0.1 percent in September. Stocks linked to potential takeovers dominated trading. Beatrice Cos. was the most active NYSE-listed issue, jumping 2 1/8 to 44 3/8. Kohlberg Kravis & Roberts, in a $5.4 billion deal, offered $45 a share in cash and securities for Beatrice.

Anheuser-Busch, the largest U.S. brewer, was second most active, climbing 2 to 37. Rumors cite Seagram or Brascan Ltd. as a possible buyer for Anheuser-Busch, which denied the rumors. Brascan, reported to be interested in acquiring the company for $50 a share, would not comment.

Among consumer products companies, Chesebrough Ponds rose 1 3/4 to 36 7/8, and Avon Products added 7/8 to 26.

Colgate Palmolive added 1 3/8 to 32 1/4 amid takeover speculation.

Quaker Oats added 2 1/4 to 59 1/8, and Kellogg rose 1 3/4 to 62.

Viacom, also the subject of takeover speculation, was the session's biggest winner, rising 5 5/8 to 59.

Pan American World Airways was unchanged in active trading.

The stock has firmed recently on reports that Resorts International might try to take over the carrier.

AT&T added 3/8 to 21 1/8. It reported higher earnings.

Some pharmaceuticals scored major gains. UpJohn advanced 4 1/4 to 120.

Merck added 2 7/8 to 112 1/2. Bristol Myers rose 1 7/8 to 58 5/8.

Among technology and semiconductor issues, IBM climbed 1 3/8 to 129 3/8, and Digital Equipment added 1 1/8 to 107 3/8. Texas Instruments rose 3/8 to 94 3/8, and Motorola was up 3/8 to 32 7/8.

Among other blue chips, Westinghouse added 3/4 to 39 5/8, General Electric rose 2 1/2 to 61 3/4, and Gulf & Western added 1 1/4 to 45.