By Anora Mahmudova and Barbara Kollmeyer, MarketWatch

Wallgreen, Time Warner losses shave off nearly 2 points off S&P 500

NEW YORK (MarketWatch) -- U.S. stocks edged higher on Wednesday, erasing early losses as investors shrugged off worries about geopolitical risks and downbeat European economic news.

Still, a lack of risk appetite globally pushed prices of safe-haven assets higher. U.S. Treasurys rallied and gold futures jumped 1.9% above $1,300 per troy ounce, while global equities fell.

The S&P 500 (SPX) was up 1.8 points, or 0.1%, at 1,921.68. The Dow Jones Industrial Average (DJI) added 12 points, or 0.1%, to 16,441. The Nasdaq Composite (RIXF) gained 4 points, or 0.1%, to 4,357.13.

Follow MarketWatch's live blog of today's stock-market action.

Quincy Krosby, market strategist at Prudential Financial, said this market has rewarded investors who bought the dips over the past five years.

"August tends to be a weak months for stocks because of seasonality. Most people around the world are on holidays, which means lower volumes. In absence of economic and corporate news, geopolitical headlines will be driving the markets," Krosby said.

In today's sole economic news, the U.S. trade deficit shrank in June, largely because imports of petroleum fell to the lowest level since late 2010. However, investor reaction was muted.

Meanwhile, Dallas Federal Reserve President Richard Fisher said after the close of Wall Street's session that the central bank may need to hike rates sooner than expected, if data continues to be as strong as the July Institute for Supply Management's service-sector index. The index reached the highest level since Dec. 2005 on Tuesday.

Also read: Here is when Fed officials forecast an interest-rate hike

Groupon, Time Warner, Sprint on the move

Among individual companies, shares of Groupon (GRPN) slid 17% after the daily-deals company posted disappointing results late Tuesday. Groupon may not be bargain stock it seems

Meanwhile, Time Warner Inc. (TWX) shares sank 12% after 21st Century Fox Inc. (NWSA) said late Tuesday that it was yanking its proposal to buy the company.

Shares of Walgreen Co.(WAG) sank 14% after the drugstore chain issued 2016 guidance well below Wall Street guidance. The drugstore also said it will keep headquarters in the U.S., news that will disappoint a group of investors trying to persuade the company to relocate its headquarters to tax-friendly Switzerland.

Combined losses from Walgreen and Time Warner shaved off approximately 2 points from the S&P 500.

Sprint (S) shares sank after it ended its pursuit of T-Mobile US Inc. (TMUS) and would replace Chief Executive Dan Hesse with billionaire entrepreneur Marcelo Claure, who is untested as a wireless operator, The Wall Street Journal reported. Sprint shares slid 18%. Read about more notable stock moves here.

European tension

News that Italy unexpectedly fell back into recession in the second quarter weighed on European stock, which were down sharply.

Stocks in Italy sank 3%, pushing down the broader Stoxx 600 index fell 1.4%. Other data showed German manufacturing orders dropping a surprising 3.2% in June on an adjusted basis, as geopolitical worries held back orders. The German DAX 30 index dropped 1.5%.

Escalating tension between Russia and Ukraine resulted in a selloff on Wall Street on Tuesday. On Wednesday, Poland's prime minister said the risk of an invasion of Ukraine by Russia has intensified.

In addition, Russian President Vladimir Putin told his government to prepare retaliatory measures against sanctions by the U.S. and Europe.

"With the Dow Jones brushing the 200-day moving average for the first time since the end of January, there will be a lot of nervous bulls out there," said Chris Beauchamp, market analyst at IG, in a note. (Read more on why stocks are down in Wednesday's Need to Know http://www.marketwatch.com/story/walgreen-to-buy-remaining-stake-in-alliance-boots-2014-08-06-61035145.)

Jitters carried over into Asia, where the Nikkei 225 index slid 1%. In other markets, Gold prices (GCU4) rallied, while oil (CLU4) held steady ahead of inventory reports due later..

More must-reads from MarketWatch:

The U.S. pump-and-dump

How you'll know if it's time for a market crash

Preparing for a Fed change of heart

Subscribe to WSJ: http://online.wsj.com?mod=djnwires