S&P 500 rides Microsoft, Amazon to record close north of 4,000