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!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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