An employee delivers cases of Coca-Cola brand soda in Miami Beach, Florida.

With the S&P 500 not far from the firm's 2018 year-end target, Goldman Sachs says there is still an investment strategy that can outperform.

The firm recommended companies with high and stable profit margins.

That's because despite the one-time boost to profit from the corporate tax cut, companies face a number of challenges to maintaining profit margins, including rising commodity prices, rising interest rates and wage growth. All of these cut into margins.

“Investors should focus on stocks with high and stable gross margins," wrote David Kostin, Goldman's chief U.S. equity strategist, in a report Friday to clients. "The market generally rewards companies with high margins when the outlook for corporate profitability weakens.”

Kostin reiterated his year-end price target of 2,850 for the S&P 500, representing just 3 percent upside from Friday’s close.

The strategist noted that Russell 1000 stocks in the top quintile of each of their sectors for stable gross profit margin levels outperformed low gross margin stocks by 14 percentage points so far this year.

“We expect the trade will continue to outperform as the margin tailwind from tax reform passes,” he said.

Here are five companies in the Goldman Sachs "high and stable gross margins" stock basket recommended by Kostin.