S&P climbs to record 5,000 level but closes lower