US Markets

Stocks fail to hold gains; dollar recovery, data eyed

Stock strategy after Yellen comments
Yellen's economic & policy outlook
Yellen: Inflation will rise 2% as economy strengthens

U.S. stocks closed lower on Friday, failing to hold highs touched during the session, as investors eyed inflation data and Fed Chair Yellen's speech ahead of the long weekend. (Tweet This)

"The narrative is you're getting a market that's looking for a liftoff in September and we're technically sailing," said Art Hogan, chief market strategist at Wunderlich Securities. "The most important thing (this week) was stability in the dollar and yields."

Hogan said it was "constructive" that the stock market continues to trade near highs despite mixed economic data.

After a pause in its recent accelerated rise, the dollar rose on Friday to post its first positive week in six. The greenback index gained more than 1 percent with the euro lower at $1.10.

Stocks moved little following an afternoon speech by Federal Reserve Chair Janet Yellen that said a rate hike would be appropriate this year if the economy improves. She noted that first quarter weakness was largely transitory and that it would take several years for rates to return to normal.

"Basically she didn't say anything really, really new," said Peter Cardillo, chief market economist at Rockwell Global Capital.

The S&P 500 and the Nasdaq failed hold gains in the close. Earlier, both indices extended gains to trade higher, with the Nasdaq briefly above its record close of 5,092.09.

Read MoreStreet wanted more from Yellen, got same old

The Dow closed near its lows for the day, about 50 points lower, despite Goldman Sachs ending about 1.4 percent higher at a 52-week high to lead blue chips gains. Financials were the week's third-best performing sector in the S&P.

"The financials have been quite strong all week," Cardillo said. "The market is looking ahead (and thinking) there will be monetary (policy) change this year. That's probably why we're seeing this strength in financials.

Art Cashin, director of floor operations at UBS, said the 0.8 percent decline in the Dow transports was weighing on equities. Pressured primarily by airlines, the index lost about 2.3 percent this week, its worst since March 27.

The transports are down 6.7 percent in the last six months, versus the Dow Jones industrial average's approximately 2.4 percent gain.

"Transports are a direct link to the economy... if we're not shipping as many products we're hurting transports," said Lance Roberts, general partner at STA Wealth Management. "This is really the big thing that worries me." He expects a slight correction this summer.

Stock index futures turned mildly negative on the inflation report and the 2-year Treasury yield topped 0.61 percent, but longer-end bond yields initially held steady before creeping higher. The 10-year yield traded near 2.22 percent.

The cash bond market closed early today at 2 p.m. ET ahead of the long weekend.

30-day DJIA performance

"Investors are starting to price in ... a rate hike some time in 2015," said Andrew W. Ferraro, wealth advisor at Strategic Wealth Partners. The consumer price index came in "a little higher. That may suggest a slightly earlier rate hike."

Fed fund futures priced in a 45 percent chance of rate hike in September, up from 40 percent earlier and 35 percent last week.

Read MoreDivergence creates spooky undercurrent for stocks

The Labor Department said on Friday its Consumer Price Index (CPI) rose 0.1 percent last month, with the core figure discounting food and energy costs up 0.3 percent, for the largest gain since January 2013.

Economists polled by Reuters had forecast the CPI edging up 0.1 percent from March and dipping 0.1 percent from a year ago.

"I think it's a decent sign for the economy," said Todd Hedtke, vice president for investment management at Allianz Investment Management. "I don't think it's a good sign for capital markets. It's been a 'goldilocks' market for so long. You're going to see some pressure. But the bottom line, the inflation inching north is a positive sign. We need to see a little more of that spending."

Read MorePay up now, but gas is going to get much cheaper

Much of the recent economic data indicated moderate growth, but not enough to warrant an interest rate hike soon.

Despite better jobs data, consumer spending and price increases were mostly muted. The Federal Reserve is watching for enough strength in employment and inflation, of which CPI is an input, to support a rate hike.

"I think it wasn't an outstanding number," TD Ameritrade chief strategist JJ Kinahan said of the CPI read. "But when you're at all-time highs and no blow-away numbers it's an excuse to sell."

Major U.S. Indexes

The Dow Jones Industrial Average closed down 53.72 points, or 0.29 percent, at 18,232, with Boeing leading laggards and Goldman Sachs and Apple the greatest advancers.

The closed down 4.75 points, or 0.22 percent, at 2,126.07, with telecommunications the greatest of nine laggards and information technology the only advancing sector.

The Nasdaq closed down 1.43, or 0.03 percent, at 5,089.36.

The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, traded near 12 after hitting a year-to-date low of 11.82.

Read MoreMarket volatility hits 2015 low

Nearly two stocks declined for every advancer on the New York Stock Exchange, with an exchange volume of 617 million and a composite volume of 2.5 billion in the close.

Crude oil futures for July settled down $1.00 at $59.72 a barrel on the New York Mercantile Exchange, marking the 10th positive week in a row. Data going back to 1983 does not show a longer stretch of consecutive gains.

Gold futures settled down 10 cents at $1,204.00 an ounce.

Microsoft and Salesforce had significant talks about an acquisition but failed to reach a deal on price differences, sources familiar with the situation told CNBC.

Earnings out on Friday included Campbell Soup, Deere, Foot Locker before market open.

Lions Gate Entertainment earnings came in 7 cents above estimates with adjusted quarterly profit of 39 cents per share, but revenue fell considerably below analyst forecasts.

BlackBerry will buy back about 2.6 percent of its outstanding shares, to negate potential negative effects of a proposed employee stock purchase plan.

Hewlett-Packard reported adjusted quarterly profit if 87 cents per share, 2 cents above estimates, though revenue was slightly shy of forecasts. The company also issued weaker-than-expected current quarter guidance. Investors are taking note of a positive development—lower-than-expected expenses for the separation of its personal computer and printer businesses into a separate company.

Deere & Co. earned $2.03 per share for its latest quarter, beating estimates of $1.55 despite a slight revenue shortfall. Deere noted a weak global agricultural sector, but said good execution aided its bottom line.

Foot Locker beat estimates by 6 cents with earnings of $1.29 per share. Revenue and same-store sales were above analyst forecasts, and the company said the quarter was the most profitable in its history.

Campbell Soup earned an adjusted 62 cents per share for its latest quarter, 10 cents above estimates, though revenue fell short due to currency effects. Campbell said its full-year sales would fall towards the lower end of its projected range, but earnings would be at the more favorable end.

Read MoreEarly movers: DE, FL, CPB, HPQ, GPS, ROST & more

European equities closed mixed on Friday as investors focused on a central bank meeting in Portugal and Yellen's speech.

Mario Draghi, president of the European Central Bank (ECB), spoke at the event in Sintra, Portugal earlier Friday. He said that the economic outlook for the euro zone is looking "brighter today than it has done for seven long years."

gained 8.1 percent for the week, its strongest since the week ending December 5, 2014, when it rose 9.5 percent.

The S&P 500 ended mildly higher on Thursday above its previous record close of 2,129.20 to post its 10th closing high for the year.

"Investors are going into this weekend knowing there isn't any catalyst to force the Fed to move anytime soon and that means we're all data-dependent," said Adam Sarhan, CEO of Sarhan Capital.

Durable goods orders and another read on first-quarter GDP come out next week.

Reuters and CNBC's Patti Domm and Peter Schacknow contributed to this report.