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

I am running PROC CORR to determine Pearson, Spearman, and Kendall correlations on 101 variables against a single variable. For example, for age, gender, race, etc. I want to see the correlation to whether the person uses the internet. The procedure is running fine and giving me the data that I want, but because I am comparing against 101 variables, the results are very wide and run off the page.

 

Is there a way to display the same results vertically, so that I have only three columns (Pearson, Spearman, and Kendall) and 101 rows?

 

SAS Univeristy Edition, release 3.5, build 3 Feb 2016.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
SURE.





proc corr data=sashelp.class  noprint   outp=pearson outs=spearman outk=kendall;
 var weight height;
 with age;
run;
data temp;
 set pearson spearman kendall indsname=indsname;
 dsn=scan(indsname,-1,'.');
 if _type_='CORR';
run;

proc transpose data=temp out=want;
 id dsn;
 var _numeric_;
run;
proc datasets library=work nolist nodetails;
 save want;
quit;


View solution in original post

4 REPLIES 4
Ksharp
Super User
Put that single variable in WITH statement, other 101 variables in VAR statement.
OR Do you want IML code ?



proc corr data=sashelp.class  noprint   outp=pearson outs=spearman outk=kendall;
 var weight height;
 with age;
run;
data temp;
 set pearson spearman kendall indsname=indsname;
 dsn=scan(indsname,-1,'.');
 if _type_='CORR';
run;

proc transpose data=temp out=want;
 id dsn;
 var _numeric_;
run;


rossj81zzz
Calcite | Level 5

Thank you, that works perfectly. Smiley Happy

 

For bonus points, is there a way that I can automatically drop the four temporary tables in the script, so that only the WANT table is left at the end?

 

Ksharp
Super User
SURE.





proc corr data=sashelp.class  noprint   outp=pearson outs=spearman outk=kendall;
 var weight height;
 with age;
run;
data temp;
 set pearson spearman kendall indsname=indsname;
 dsn=scan(indsname,-1,'.');
 if _type_='CORR';
run;

proc transpose data=temp out=want;
 id dsn;
 var _numeric_;
run;
proc datasets library=work nolist nodetails;
 save want;
quit;


rossj81zzz
Calcite | Level 5

Excellent. Thanks very much for your help.

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
  • 4 replies
  • 2189 views
  • 1 like
  • 2 in conversation