The S&P 500 rose for the seventh consecutive month in August as U.S. markets fell slightly on Tuesday.