(Reuters) - The benchmark S&P 500 eked out a gain on Wednesday as strength in the energy and consumer sectors offset declines in financial shares and investors began looking ahead to first-quarter earnings season.

The Dow Jones Industrial Average ended slightly lower, falling for the ninth session out of the past 10, while the Nasdaq rose for a fourth straight day.

Investors have been assessing what the Republicans’ failure to pass a healthcare bill means for tax reform and the rest of President Donald Trump’s agenda, hopes for which have helped drive stocks to record highs.

They are looking to first-quarter earnings to support lofty valuations for stocks, with the S&P 500 trading at nearly 18 times earnings estimates for the next 12 months against its long-term average of 15 times.

First-quarter earnings for S&P 500 companies are expected to rise 10.1 percent, according to Thomson Reuters I/B/E/S.

“The policy risk has increased ... but economic data still remains solid and therefore earnings should be good,” said Walter Todd, chief investment officer of Greenwood Capital in Greenwood, South Carolina. “Absent some revelation on the policy front, I think that’s the next catalyst for the market, is when we start seeing companies report.”

The Dow Jones Industrial Average .DJI fell 42.18 points, or 0.2 percent, to 20,659.32, the S&P 500 .SPX gained 2.56 points, or 0.11 percent, to 2,361.13 and the Nasdaq Composite .IXIC added 22.41 points, or 0.38 percent, to 5,897.55.

Slideshow ( 7 images )

The energy sector .SPNY gained 1.2 percent, leading all sectors, supported by stronger oil prices CLc1.

The consumer discretionary sector .SPLRCD rose 0.6 percent as retailers such as Nordstrom JWN.N and Kohl's KSS.N surged. Amazon.com AMZN.O rose 2.1 percent and hit an all-time high, giving the biggest boost to the S&P 500 and Nasdaq.

Financial shares .SPSY fell back 0.5 percent a day after leading a rally.

Investors also digested comments from Federal Reserve officials. Chicago Fed President Charles Evans said he favors further interest rate hikes this year, while Boston Fed President Eric Rosengren said the Fed should raise rates three more times in 2017.

“The market seems to be unfazed by the fact that the Fed is looking to be somewhat aggressive in raising rates,” said Paul Nolte, portfolio manager at Kingsview Asset Management in Chicago.

The stock rally fueled by optimism President Donald Trump will boost the economy may be near its peak, according to a Reuters poll of strategists, who forecast U.S. shares will gain less than 3 percent between now and year-end.

Slideshow ( 7 images )

In corporate news, Vertex Pharmaceuticals VRTX.O soared 20.5 percent after the company's cystic fibrosis treatment succeeded in a late-stage study. The stock boosted the S&P and helped drive the Nasdaq Biotechnology index .NBI up 0.9 percent.

About 5.8 billion shares changed hands in U.S. exchanges, well below the 6.9 billion daily average over the last 20 sessions and among the lightest volume days in 2017.

Advancing issues outnumbered declining ones on the NYSE by a 1.88-to-1 ratio; on Nasdaq, a 1.59-to-1 ratio favored advancers.

The S&P 500 posted 14 new 52-week highs and 1 new lows; the Nasdaq Composite recorded 86 new highs and 24 new lows.