Stocks End Higher for the Week, Led by Energy

Stocks closed higher after struggling to find direction much of the day amid light volume and ahead of a week filled with economic data.

The Dow Jones Industrial Averagerose 47.53 points, or 0.5 percent, to close at 10,462.77. The blue-chip index was up 14.84 points for the week, or 0.14 percent. With this week's action, the Dow edged into positive territory for the year, up 0.3 percent.

General Electric , Pfizer and Merck led the Dow higher for the week, while Hewlett-Packard and American Express fell.

The S&P 500 rose 5.37 points, or 0.5 percent, to 1,109.55. The broad index rose 5 points, or 0.5 percent, for the week, but is still lower for the year. The S&P was pushed higher by JDS Uniphase, which rose 11.8 percent for the week, and Oracle, which rose 9.3 percent.

The Nasdaq rose 6.28 points, or 0.3 percent, to 2,242.48. The tech-heavy index rose 8.73 points this week, or 0.4 percent, but is still slightly down for the year. Oracle also pushed the Nasdaq higher, as did Adobe , which rose 9.2 percent.

The CBOE Volatility Index, widely considered the best gauge of fear in the market, fell below 22.

Energy, health care and consumer discretionary gained, while utilities slipped.

All the major indexes are up more for the month: the Dow rose 4.5 percent, the S&P 500 rose 5.7 percent and the Nasdaq rose 6.1 percent. Volume has been light all week, however, with fewer than 1 billion shares changing hands daily on the New York Stock Exchange.

On Friday, only 756 million shares traded on the NYSE, with advancers outpacing decliners nearly 2 to 1.

"Volume is still very, very light in this market, and news is light as well," said Alan Gayle, senior investment strategist at RidgeWorth Investments. "The market is drifting higher in the absence of any definitive, fundamental news."

Energy stocks were higher all day after oil rose above $76 a barrel, sparked by the shutdown of a major Enbridge pipeline to the Midwest and rising gasoline cash prices in the Chicago region and the U.S. Gulf Coast.

Most of the oil drillers were higher, including Transocean and Diamond Offshore .

Also, PG&E shares plunged more than 7 percent after the electric company's natural gas pipeline explosion ripped through a neighborhood near San Francisco, starting fires that killed at least four and burned more than 50 homes.

And BP was slightly higher after the oil giant said it will delay the release of third-quarter results by a week to add the costs associated with the Gulf of Mexico oil spill.

In the technology sector, HP shares fell more than 1 percent following news U.S. investigators are widening their probe of alleged kickbacks paid to Russian authorities by employees of a Hewlett-Packard subsidiary in Germany.

Dell slumped after Morgan Stanley downgraded their rating on the PC maker to "underweight" from "equalweight."

Cisco fell slightly after brokerage RBC downgraded its rating on the tech giant to "outperform" from "top pick" and cut its price target to $26 from $28.

Apple fell slightly after the iPod maker, in a reversal, made it easier for third parties to build applications and software for the iPhone and the iPad.

Chipmakers also took a beating in the wake of several analyst downgrades and weak outlooks. National Semiconductor tumbled after the chipmaker issued a weak outlook. In addition, at least four brokerages cut their price targets on the firm.

Similarly, Texas Instruments slipped after the semiconductor giant narrowed its earnings and revenue outlook but kept the mid-point of its forecast range. Stifel Nicolaus and Jefferies both cut their price targets on TI to $29 from $32 and $37, respectively.

Meanwhile, Nokia rose after news it has replaced its CEO with a Microsoft executive, to better fight fierce competition in the market for smartphones. Microsoft shares slipped. RBC raised its rating on Nokia to "outperform" from "sector perform" and raised its price target to $14 from $12.

And Facebook overtook Google in minutes spent by users, according to new data from researchers at comScore.

Research In Motion , meanwhile, slipped amid rumors the smartphone maker may eventually be acquired by Microsoft. Speculators said Microsoft has so much cash that the acquisition is conceivable.

Health care stocks got a boost from Stifel Nicolaus, which began to cover several biotech companies with "buy" ratings, citing strong demand.

Acorda Therapeutics soared more than 4 percent, while Celgene was up more than 3 percent. Rival Amgen also rose, while Human Genome Sciences fell slightly.

Lululemon Athletica soared more than 10 percent after the yoga and running-wear retailer raised its full-year financial forecasts as it reported its quarterly profit more than doubled.

Moody's Investors Service surged, leading the S&P 500 higher after ratings upgrades. Piper Jaffray cited improving near-term revenue trends and an easing of regulatory concerns for the ratings agency. Shares of McGraw-Hill , parent of rival Standard & Poor's, also rose.

In M&A news, 3M said it will buy medical products company Arizant for $810 million in cash. The purchase is 3M's third purchase in recent weeks.

In Europe, investors wondered whether Deutsche Bank's $11.4 billion stock sale would be needed because of new Basel III rules forcing banks to get more capital.

In the day's economic news, the government reported earlier Friday that U.S. wholesale inventories soared 1.3 percent in July, much better than the forecasted 0.5 percent. While positive, Gayle at RidgeWorth Investments described the growth as "transitory."

"Our expectation is those gains won’t continue as businesses become more comfortable with what they own on hand," Gayle said.

President Obama held a press conference where he faulted Republicans for stalling progress on turning around the economy. Obama also announced long-time economic adviser, Austan Goolsbee, will replace Christina Romeras chairman of the Council of Economic Advisers. Romer returned to teaching at the University of California, Berkeley.

Next week also features several key economic releases. The two “market movers” will be Tuesday's retail sales and Wednesday's industrial production, said Peter Cardillo, chief market economist at Avalon Partners.

Cardillo said he is optimistic the numbers will reveal the worst news on the economy is past. If the data proves him right, the market will move higher, he said.

“I think there’s a shift in sentiment, from being overly negative to a more cautious outlook,” Cardillo said.

On the Calendar Next Week:

MONDAY: Treasury budget
TUESDAY: NFIB small business optimism, retail sales, IBD/TIPP economic optimism index, business inventories, UN General Assembly, API weekly report; before-the-bell earnings from Kroger and Best Buy
WEDNESDAY: MBA mortgage applications, Empire State manufacturing survey, import and export prices, industrial production, weekly oil inventories
THURSDAY: PPI, current account, jobless claims, Phili Fed survey; before-the-bell earnings from FedEx, after-the-bell earnings from Oracle and Research In Motion
FRIDAY: CPI, consumer sentiment

More From CNBC.com: