I use Proc freq to calculate the Somers' D between the dependent variable (log salary) and the independent variable (crhits, crhome, etc.)
Is there a way to get the all the results in one proc freq statement?
The code I use currently is
DATA baseball;
SET sashelp.baseball;
RUN;
PROC SORT
DATA = baseball;
BY team;
RUN;
PROC FREQ
DATA = baseball
;
TABLES logsalary * crhits
/
MEASURES;
OUTPUT OUT = somersd
(KEEP = team N _SMDCR_
RENAME = (_SMDCR_ = somers_d
N = num_in_group))
MEASURES;
BY team;
RUN;
I'm looking to get the output "somersd" for each variable crhits, crhome, etc. in one table and to do this all in one procedure, is this possible?
Why not just transpose the data so that the independent variable becomes a new BY group?
proc transpose data=sashelp.baseball out=tall name=stat;
by name team logsalary notsorted;
var crhits crhome;
run;
proc sort;
by team stat;
run;
ods exclude all;
PROC FREQ DATA = tall ;
BY team stat;
TABLES logsalary * col1 / MEASURES;
output measures out=measures
(KEEP = team stat N _SMDCR_
RENAME = (_SMDCR_ = somers_d N = num_in_group)
)
;
RUN;
ods exclude none;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.