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;
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!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.