How can I display PROC CORR results vertically?

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

How can I display PROC CORR results vertically?

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.

 


Accepted Solutions
Solution
‎09-11-2016 11:54 AM
Super User
Posts: 9,875

Re: How can I display PROC CORR results vertically?

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


All Replies
Super User
Posts: 9,875

Re: How can I display PROC CORR results vertically?

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;


New Contributor
Posts: 3

Re: How can I display PROC CORR results vertically?

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?

 

Solution
‎09-11-2016 11:54 AM
Super User
Posts: 9,875

Re: How can I display PROC CORR results vertically?

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;


New Contributor
Posts: 3

Re: How can I display PROC CORR results vertically?

Excellent. Thanks very much for your help.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 339 views
  • 1 like
  • 2 in conversation