BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jamie_H
Fluorite | Level 6

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:

 

WantWant

Please bear in mind that these are made up variables, and in total there about 20. 

 

Many thanks!

Jamie

 

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

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

 

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

I do not grasp the logic that lets you go from input data to output table. Please explain.

--
Paige Miller
ed_sas_member
Meteorite | Level 14

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

 

Jamie_H
Fluorite | Level 6

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!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1466 views
  • 4 likes
  • 3 in conversation