BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kwil
Fluorite | Level 6

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?

kwil_1-1604016970254.png

 

 

Thanks in advance. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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

  1. https://www.stata.com/manuals13/rsignrank.pdf 
  2. PROC UNIVARIATE documentation, details section "Wilcoxon Signed Rank Test"

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).

View solution in original post

4 REPLIES 4
SteveDenham
Jade | Level 19

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.

 

 

FreelanceReinh
Jade | Level 19

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

  1. https://www.stata.com/manuals13/rsignrank.pdf 
  2. PROC UNIVARIATE documentation, details section "Wilcoxon Signed Rank Test"

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).

kwil
Fluorite | Level 6
Thanks very much, works great!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

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.

Discussion stats
  • 4 replies
  • 2761 views
  • 3 likes
  • 4 in conversation