The S&P 500 notched a new record high this week but mid-week setbacks led to the index’s first weekly loss in almost a month.