Hi,
I am testing the significance of the median in my sample using the one sample Wilcoxons signed rank test through proc univariate. However, the ouput presents an S statistic and for reporting purposes I would like to report the commonly used Z statistic. Is there any easy way of getting the Z statistic in SAS or would it be easier using another program like Stata?
Thanks in advance.
Hi @kwil,
If your sample does neither contain two equal values ("ties") nor zeros, I would calculate the z statistic as follows (using x as the variable name) -- otherwise it would be more complicated:
proc univariate data=have noprint;
var x;
output out=stats signrank=S n=n;
run;
data want;
set stats;
z=S/sqrt(n*(n+1)*(2*n+1)/24);
run;
This is based on
Note that SAS does not use the z statistic, but a tn-1 distributed statistic for the p-value computation, which is why the p-value based on the former (0.0327) differs slightly from the p-value in your output (0.0310).
You can use PROC NPAR1WAY in SAS.
Another way would be to use the CDFquantile('normal') function, plugging in the p value to get the Z value.
The only issue here is that S really is not normally distributed. For small n, an exact p value is computed. For large n (n>20), there is a function of S that is t distributed (see the Details\Tests for Location part of the UNIVARIATE documentation). I don't see any reference to a Z score for the Signed Rank statistic in the SAS documentation or in my copy of Hollander and Wolfe, which also uses an approximate t distribution.
SteveDenham.
Hi @kwil,
If your sample does neither contain two equal values ("ties") nor zeros, I would calculate the z statistic as follows (using x as the variable name) -- otherwise it would be more complicated:
proc univariate data=have noprint;
var x;
output out=stats signrank=S n=n;
run;
data want;
set stats;
z=S/sqrt(n*(n+1)*(2*n+1)/24);
run;
This is based on
Note that SAS does not use the z statistic, but a tn-1 distributed statistic for the p-value computation, which is why the p-value based on the former (0.0327) differs slightly from the p-value in your output (0.0310).
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.