I have a table that contains individual rows of data for customers, with various other variables that have a 1 or a 0. You can use this to get a feel for what I mean:
data have;
input ID ColumnA StatusB CategoryF UnderPerf;
datalines ;
1 1 0 0 1
2 1 0 1 1
3 0 1 1 1
4 0 0 0 0
5 1 1 1 1
;
run;
What I would like off the back of this is to get a frequency of each of the variables by each other in one big matrix such as this:
Please bear in mind that these are made up variables, and in total there about 20.
Many thanks!
Jamie
HI @Jamie_H
You can use PROC CORR to achieve this (cf. similar post https://communities.sas.com/t5/SAS-Programming/Calculating-Product-Overlap-in-a-Basket/m-p/631529#M1... and great @Ksharp solution!)
proc corr data=have out=have_corr sscp noprint ;
var ColumnA StatusB CategoryF UnderPerf;
run;
data want;
set have_corr;
where _type_='SSCP' and _name_ ne 'Intercept';
keep _name_ ColumnA StatusB CategoryF UnderPerf;
run;
I do not grasp the logic that lets you go from input data to output table. Please explain.
HI @Jamie_H
You can use PROC CORR to achieve this (cf. similar post https://communities.sas.com/t5/SAS-Programming/Calculating-Product-Overlap-in-a-Basket/m-p/631529#M1... and great @Ksharp solution!)
proc corr data=have out=have_corr sscp noprint ;
var ColumnA StatusB CategoryF UnderPerf;
run;
data want;
set have_corr;
where _type_='SSCP' and _name_ ne 'Intercept';
keep _name_ ColumnA StatusB CategoryF UnderPerf;
run;
That's perfect Ed and so useful to get to play with a Proc that I had heard of before but never had the opportunity to use.
Many thanks!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.