By Anora Mahmudova and Barbara Kollmeyer, MarketWatch

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

NEW YORK (MarketWatch) -- U.S. stocks ended Wednesday marginally higher, as investors remained cautious in the wake of heightened geopolitical risks and downbeat European economic news.

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

The S&P 500 (SPX) flat at 1,920.23. The Dow Jones Industrial Average (DJI) gained 13.87 points, or 0.1%, to 16,443.34. The Nasdaq Composite (RIXF) added 2.22 points to 4,355.05.

Read the recap of 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 month for stocks because of seasonality. Most people around the world are on holiday, 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. Reaction to stronger-than-expected economic data over the past few weeks had been generally negative, as investors worry that accelerating growth may force the Federal Reserve to start raising rates sooner than currently anticipated.

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 13% 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 13% after 21st Century Fox Inc. (NWSA) said late Tuesday that it was withdrawing its proposal to buy the company. 21st Century Fox shares rose 2.3%.

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.

Cognizant Technology Solutions Corp. (CTSH) shares plummeted 13% after the information-technology company cut its revenue guidance for the year and projected third-quarter revenue that missed analysts' expectations.

Combined losses from Walgreen, Time Warner and Cognizant shaved off approximately 2.5 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 19%. 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) jumped above $1,300 per troy ounce, while oil (CLU4) held steady.

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