0
votes

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?

1

1 Answers

1
votes

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;