S&P 500, Nasdaq edge higher after upbeat earnings reports