我使用Proc freq来计算因变量(对数工资)和自变量(点击数,crhome等)之间的Somers'D。
有没有办法在一个proc freq语句中获得所有结果?
我当前使用的代码是
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;
我希望在一张表中获取每个变量crhits,crhome等的输出“ somersd”,并在一个过程中全部完成,这有可能吗?
答案 0 :(得分:1)
为什么不只是转置数据以使自变量成为新的BY组?
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;