S&P, Nasdaq rise to record closes