0

I am looking to produce the Somers' D using Proc Freq using the following code:

DATA HAVE;
    DO I = 1 TO 1000;
        Y = RANUNI(0);
        X = RANUNI(1) * 10;
        OUTPUT;
    END;
RUN;
PROC FREQ 
    DATA=have           
    NOPRINT;
          TABLES y * x / MEASURES;
          OUTPUT OUT=somersd
          (KEEP = _SMDCR_
          RENAME = (_SMDCR_ = somers_d))
          MEASURES;
RUN;    /*This is somers' D for Somers’ D(C|R)*/

I read from the documentation that the above code tests concordinance on Y as the column and X as the row, but I wanted to make sure this is the case:

Now, which is the correct way to test for concordance is it

y * x

or

x * y

Any help will be appreciated

1 Answers1

0

From the tables documentation:

A request is composed of one variable name or several variable names separated by asterisks. To request a one-way frequency table, use a single variable. To request a two-way crosstabulation table, use an asterisk between two variables. To request a multiway table (an n-way table, where n>2), separate the desired variables with asterisks. The unique values of these variables form the rows, columns, and strata of the table.

It's not very clear, but essentially the first variable corresponds to the row index variable and the second to the column index value. Watch out - the row index values are the values that lie along the vertical axis and the column index values are the values that lie along the horizontal axis. This often leads to inadvertently inverting rows and columns, as the row index values form a column and the column index values form a row!

In your case,

PROC FREQ DATA=have;
  TABLES y * x / MEASURES;
RUN;

will calculate Somers' D(C|R) assuming that X is the independent variable and Y is the dependent variable, which I think is what you want.

Community
  • 1
  • 1
rxg
  • 3,777
  • 22
  • 42