Posts: 5,043

# Proc FREQ : How to get the sign of stratum-adjusted Spearman correlations

Hello,

The CMH statistic calculated on RIDIT scores (proc FREQ) takes the value (n-1)*Rs**2 where Rs is the Spearman rank correlation. This is of interest with multi-level tables, because it is the only way in SAS to get a stratum-adjusted Spearman correlation. How can I get the sign of Rs?

PG

PG
SAS Super FREQ
Posts: 3,831

## Re: Proc FREQ : How to get the sign of stratum-adjusted Spearman correlations

You can get Spearmen coefficients from PROC CORR with the SPEARMAN option. For example, the Spearman coefficient for the following data is 0.36332 and n=21.  The CMH statistic is (21-1)*(0.36332)**2 = 2.6400

data test;
call streaminit(1);
do i = 1 to 21;
x = rand("table", 0.5, 0.3, 0.2);
y = rand("table", 0.5-x/10, 0.3, 0.2+x/10);
output;
end;
run;

proc corr data=test spearman noprob;
var x y;
run;

proc freq data=test;
tables x*y / scores=ridit cmh norow nopercent nocol;
run;

Posts: 5,043

## Re: Proc FREQ : How to get the sign of stratum-adjusted Spearman correlations

Thanks. But my question is about stratum-adjusted correlations. As with TABLES A*x*y / ...

PG

PG
Super User
Posts: 11,767

## Re: Proc FREQ : How to get the sign of stratum-adjusted Spearman correlations

Proc corr;

by A;

I would think would do it.

Posts: 5,043

## Re: Proc FREQ : How to get the sign of stratum-adjusted Spearman correlations

In proc freq, strata play a distinct role from BY analysis. A stratum-adjusted correlation is not the same as correlations by stratum. The former is a single coefficient of within strata relationship, the later are multiple coefficients, one for each stratum. - PG

PG
SAS Employee
Posts: 340

## Re: Proc FREQ : How to get the sign of stratum-adjusted Spearman correlations

What about dummy coding the strata variable, then using proc corr and putting all the dummy variables in the partial statement? (I haven't checked the validity of this approach.)

Posts: 2,655

## Re: Proc FREQ : How to get the sign of stratum-adjusted Spearman correlations

Hmm, that sounds logical to me--partialling out the strata effect ought to at least get the sign correct.

Steve Denham

Posts: 5,043