The S&P 500 health care index <.SPXHC> gained 0.5 percent and was among the day's best-performing sectors, led by shares of Eli Lilly (>> Eli Lilly and Co).

Eli Lilly hit a 14-year high, closing up 4.1 percent at $86.59, with investors anticipating data from an extended trial of an experimental Alzheimer's drug that could become available to doctors in the coming weeks.

S&P utilities <.SPLRCU> rose 0.7 percent, the day's strongest sector, as U.S. bond yields retreated. Utilities and other dividend payers tend to compete with bonds for investment money.

U.S. retail sales increased 1.2 percent in May, more than expected, as households boosted purchases of automobiles and a range of other goods even as they paid a bit more for gasoline. The S&P retail index <.SPXRT> was up 0.2 percent.

"You had good retail sales today and slightly above expectations. Remember how weak retail sales were in the winter, so you would expect a bounceback here," said Tim Ghriskey, chief investment officer of Solaris Group in Bedford Hills, New York.

The Dow Jones industrial average <.DJI> rose 38.97 points, or 0.22 percent, to 18,039.37, the S&P 500 <.SPX> gained 3.66 points, or 0.17 percent, to 2,108.86 and the Nasdaq Composite <.IXIC> added 5.82 points, or 0.11 percent, to 5,082.51.

Solid retail sales data followed robust May job growth numbers and stabilizing manufacturing activity, suggesting the economy is gaining momentum after a slow start in the second quarter.

Caution remained over Greece. The International Monetary Fund said its delegation had halted negotiations in Brussels and flown home because of differences with Athens.

Citrix Systems (>> Citrix Systems, Inc.) rose 6.7 percent to $70.39 after shareholder Elliott Management said the software maker should sell some units, cut costs and buy back shares.

Krispy Kreme (>> Krispy Kreme Doughnuts) soared 13.9 percent to $19.81. The doughnut chain raised the bottom end of its 2016 profit forecast.

Hess (>> Hess Corp.) rose 4.9 percent to $68.83. The oil and natural gas producer said it would sell half of its Bakken midstream assets to a private equity firm for $2.68 billion.

After the bell, shares of Twitter (>> Twitter Inc) rose 8.5 percent as it said Dick Costolo is stepping down as chief executive.

Advancing issues outnumbered declining ones on the NYSE by 1,866 to 1,204, for a 1.55-to-1 ratio on the upside; on the Nasdaq, 1,403 issues rose and 1,348 fell for a 1.04-to-1 ratio favoring advancers.

The S&P 500 posted 31 new 52-week highs and two new lows; the Nasdaq recorded 118 new highs and 27 new lows. About 5.7 billion shares changed hands on U.S. exchanges, below the 6.1 billion daily average for June so far, according to BATS Global Markets.

(Editing by Meredith Mazzilli and Nick Zieminski)

By Caroline Valetkevitch