- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you, that works perfectly.
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Excellent. Thanks very much for your help.