IBM (NYSE:IBM) said on Monday it would buy Canada's Cognos Inc (Nasdaq:COGN) for $5 billion, snapping up the last major independent maker of business intelligence software.

Investors had expected the deal after SAP AG bid 4.8 billion euros ($6.8 billion) for Cognos rival Business Objects SA in October and Oracle Corp (Nasdaq:ORCL) acquired Hyperion Solutions Corp in April for $3.3 billion.

All three targets make software that combs through vast amounts of data to analyze business trends. For example, Harrah's Entertainment Inc (NYSE:HET) uses one Cognos program to keep frequent gamblers coming back to its casinos. Automaker BMW runs a package that creates product quality and human resources reports.

International Business Machines Corp said it signed an agreement to buy Cognos for $58 a share, a 9.5 percent premium to its Friday closing price of $52.98 on the Nasdaq. IBM expects the deal to close in the first quarter of 2008.

Cognos's U.S. shares rose to $57.06 in Nasdaq trading on Monday morning and have gained 27 percent since the SAP deal for Business Objects on October 7. IBM shares rose nearly 1 percent to $101.61 on the New York Stock Exchange.

This is an effort by IBM to stay relevant in the software space, said Rebecca Wettemann, an analyst with Nucleus Research.

Oracle, SAP and now IBM are investing in business intelligence software to boost the allure of their product portfolios. Such programs interface with popular databases sold by Oracle and IBM, as well as business management software from SAP and Oracle.

Steve Mills, senior vice president and group executive of IBM Software Group, said he had been looking for several years to add business intelligence programs to IBM's products to offer more real-time and higher-performance analyses.

We started looking at this set of issues a number of years ago, Mills told Reuters in an interview. Our actions here were not per se triggered by the fact that other purchases have happened.

Software is the fastest-growing and most profitable division of IBM, the world's largest technology services company. IBM also uses software products to get customers to buy its consulting services and hardware.

Mills declined to say what other acquisitions might be in the works.

Investors have long speculated that the most likely buyer for Cognos was IBM, which has worked with Cognos for more than 15 years. They have integrated some of their technology to serve joint customers, such as the New York City Police Department, MetLife Inc (NYSE:MET) and Bayer UK.

When asked about IBM's deal for Cognos, SAP CEO Henning Kagermann said at its investor day in Germany, I would say it proves that SAP's acquisition of Business Objects was a strategically important one.

Cognos, based in Ottawa, has about 4,000 employees and more than 25,000 customers. It is IBM's 23rd acquisition.

IBM said it plans to integrate Cognos as a group within its Information Management Software division to be led by Cognos President and CEO Rob Ashe, reporting to General Manager Ambuj Goyal.

(Additional reporting by Georgina Prodhan in Frankfurt; writing by Tiffany Wu; editing by Lisa Von Ahn and John Wallace)