NEW YORK — It was another record day for stocks, but barely.

The Standard & Poor’s 500 index closed at an all-time high Monday, but by a small margin.

The S&P 500 edged up 2.34 points, or 0.1 percent, to a record 1,762.11 after good news from J.C. Penney offset disappointing earnings from a few U.S. companies.

J.C. Penney rose the most in the index after the retailer’s CEO said sales were improving. That helped stocks overcome poor earnings and a weak forecast from drugmaker Merck. Roper Industries, a medical and industrial equipment manufacturer, also lowered its earnings estimate for the year.

In other trading, the Dow Jones industrial average edged down 1.35 points, or less than 0.1 percent, to 15,568.93. The Nasdaq composite closed down 3.23 points, or 0.1 percent, at 3,940.13.

J.C. Penney, which is trying to recover from a botched corporate makeover led by its former CEO, rose 60 cents, or 8.8 percent, to $7.39. The stock is still down 63 percent this year.