US stocks climb, with S&P 500 not far from record