Solved
New Contributor
Posts: 3

# Association Rules Matrix

Hello everyone,

I'm using SAS Base/ SAS Enterprise Guide and I'm stuck.
I need to create the Association Rules matrix to calculate the support, lift, confidence and other association metrics.

My table is similar to: (one line per client with all the products associated to)

data test;
input item1 item2 item3 item4 ;
datalines ;
1 0 1 0
1 1 1 0
1 0 1 0
1 0 1 1
;

As you know for the market basket analysis I want something like that:

item1 item2 item3 item4

item1   4         1       4        1

item2   1         1       1        0

item3    4        1       4        1

item4    1         0      4        4

Accepted Solutions
Solution
Tuesday
Super User
Posts: 23,237

## Re: Association Rules Matrix

This may be of interest as well: http://clarioanalytics.github.io/marketbasket/

All Replies
Super User
Posts: 23,237

## Re: Association Rules Matrix

[ Edited ]

Here's a nifty little trick using PROC CORR:

``````data test;
input item1 item2 item3 item4 ;
datalines ;
1 0 1 0
1 1 1 0
1 0 1 0
1 0 1 1
;

ods output sscp=want;
proc corr data=test sscp;
var item1-item4;
run;

proc print data=want;
run;``````

PS. Thank you for providing sample data as a data step!

@alorenzo wrote:

Hello everyone,

I'm using SAS Base/ SAS Enterprise Guide and I'm stuck.
I need to create the Association Rules matrix to calculate the support, lift, confidence and other association metrics.

My table is similar to: (one line per client with all the products associated to)

data test;
input item1 item2 item3 item4 ;
datalines ;
1 0 1 0
1 1 1 0
1 0 1 0
1 0 1 1
;

As you know for the market basket analysis I want something like that:

item1 item2 item3 item4

item1   4         1       4        1

item2   1         1       1        0

item3    4        1       4        1

item4    1         0      4        4

Solution
Tuesday
Super User
Posts: 23,237

## Re: Association Rules Matrix

This may be of interest as well: http://clarioanalytics.github.io/marketbasket/
New Contributor
Posts: 3

## Re: Association Rules Matrix

THanks a lot it's perfect
☑ This topic is solved.