简体   繁体   English

SAS:一次按组处理所有变量的频率?

[英]SAS: Proc freq by group for all variables at once?

I use Proc freq to calculate the Somers' D between the dependent variable (log salary) and the independent variable (crhits, crhome, etc.) 我使用Proc freq来计算因变量(对数工资)和自变量(点击数,crhome等)之间的Somers'D。

Is there a way to get the all the results in one proc freq statement? 有没有办法在一个proc freq语句中获得所有结果?

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? 我希望在一张表中获取每个变量crhits,crhome等的输出“ somersd”,并在一个过程中全部完成,这可能吗?

Why not just transpose the data so that the independent variable becomes a new BY group? 为什么不只是转置数据以使自变量成为新的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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM