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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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