Solved

# How do I do a Sumif on a number of columns in SAS

Posted on 2010-01-06

consider the following table

Cust Nanme Product A Product B Product C Product D

Jason 1 0 1 0

Michael 0 1 0 1

Mary 1 0 0 0

Its a table with customer as a column and in remaining columns are 1/0 columns which indicate whether a customer has bought product A, B, C, D etc. The table above only has four products - the actual table I am dealing with has 2000 columns or products, plus millions of customers. According to above table, Jason buys Product A and D. The question I need to answer is how many customer who buy product A also buy product B, how many customers who buy product A also buy product C, how many customers who buy product A also buy product D. After doing all the A's I would need to do the B's ie How many people who buy B also buy C, how many people who buy B also buy D and so on until all possible product combination pairs are covered. What is the most efficent way to do this in SAS. I was thinking if I could do something similar to Sumif in excel I could get my question answered. However any help or comments much appreciated.