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:
Want
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;
Capture d’écran 2020-03-16 à 16.40.01.png
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;
Capture d’écran 2020-03-16 à 16.40.01.png
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!
CFC_SAS_Communities_400x225.jpg
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.
Ready to level-up your skills? Choose your own adventure.