US stocks rise as S&P 500 falls short of 5,000 milestone