NEW YORK, JAN. 18 -- The stock market struggled to a small gain today in the quietest session so far in 1988.

The dollar, meanwhile, drifted mostly lower in light trading.

The Dow Jones average of 30 industrials, which had climbed 39.96 points on Friday, rose 7.79 to 1963.86. Advancing issues outnumbered declines by about 7 to 5 on the New York Stock Exchange.

Big Board volume totaled 135.10 million shares, down from 197.94 million in the previous session. A good part of the total activity occurred in utility stocks that were the target of large-scale trading strategies focused on the companies' dividend payments.

Analysts said they hadn't expected much to happen in the market, since many investors were observing the federal holiday for Martin Luther King Jr.'s birthday. The bond market was closed.

In addition, they said, the mood in the financial world was generally subdued following last Friday's report of a big improvement in the nation's trade deficit for November.

The dollar and the bond market greeted the news with strong rallies. But stocks, after a quick runup at Friday's opening, leveled off thereafter in what some observers described as a disappointing performance.

Takeover news and rumors sparked gains in a smattering of individual stocks.

Sterling Drug rose 3 1/4 to 77 3/8. The company opposed Hoffman-La Roche's $72-a-share takeover offer and said it was negotiating elsewhere.

IU International gained 3/4 to 19 1/4. Neoax Inc. raised its bid to acquire the company from $17.50 to $19 a share, but IU said its directors rejected the offer as inadequate.

Heavily traded utilities included Pacificorp, up 1/8 at 33 1/2; Idaho Power, up 3/8 at 23 3/8; Sierra Pacific Resources, unchanged at 22 1/4, and New York State Electric & Gas, down 3/8 at 20 1/4.

The volume in those four issues amounted to nearly 38 million shares.

Among the blue chip and technology stocks, Procter & Gamble rose 1 5/8 to 86 1/8; Digital Equipment 2 1/2 to 121 1/2, and Merck 2 3/8 to 153.

But International Business Machines dropped 1 1/4 to 117 3/4 and Hewlett-Packard lost 1 1/8 to 55 7/8.

NCR fell 2 7/8 to 58 1/4 amid some evident disappointment over the size of the quarterly earnings gain posted by the company. NCR said it earned $1.79 a share in the fourth quarter, up from $1.39 in the comparable period a year earlier.

As measured by Wilshire Associates' index of more than 5,000 actively traded stocks, the market increased $3.46 billion, or 0.14 percent, in value.

The NYSE's composite index of all its listed common stocks edged up 0.08 to 141.24.

Nationwide turnover in NYSE-listed issues, including trades in those stocks on regional exchanges and in the over-the-counter market, totaled 153.86 million shares.

Standard & Poor's index of 400 industrials dropped 0.32 to 290.26, and S&P's 500-stock composite index was down 0.17 at 251.88.

The Nasdaq composite index for the over-the-counter market gained 0.39 to 340.53.

At the American Stock Exchange, the market value index closed at 269.21, up 0.90.

In Tokyo, the dollar rose briefly above 131 Japanese yen for the first time in more than a month but eased to close at 130.50 yen, up from 126.95 yen on Thursday.

Tokyo markets had been closed Friday for a national holiday.

In later London trading, the dollar was quoted at 130.20 yen.

In New York, where trading was limited because of the King holiday, the dollar slipped to 129.60, compared with 130.95 late Friday.