Example 47.2: The Exact Wilcoxon TwoSample Test
Researchers conducted an experiment to compare the effects of two stimulants.
Thirteen randomly selected subjects received the first stimulant and six
randomly selected subjects received the second stimulant. The reaction times
(in minutes) were measured while the subjects were under the influence of the
stimulants.
The following SAS statements create the data set React, which contains the
observed reaction times for each stimulant. The variable Stim represents
Stimulant 1 or 2. The variable Time contains the reaction times observed
for subjects under the stimulant.
data React;
input Stim Time @@;
datalines;
1 1.94 1 1.94 1 2.92 1 2.92 1 2.92 1 2.92 1 3.27
1 3.27 1 3.27 1 3.27 1 3.70 1 3.70 1 3.74
2 3.27 2 3.27 2 3.27 2 3.70 2 3.70 2 3.74
;
PROC NPAR1WAY tests the null hypothesis that there is no
difference between the effects of the two stimulants against an alternative
hypothesis that stimulant 1 has smaller reaction times than stimulant 2.
The WILCOXON option specifies that Wilcoxon scores are to be used. The CLASS
statement specifies that the variable Stim determines the classes.
The VAR statement identifies Time as the response variable. The EXACT option
requests the exact pvalues. Since the sample size is small, the normal
approximation may not be completely accurate, and it is appropriate to
compute the exact test.
proc npar1way wilcoxon data=React;
class Stim;
var Time;
exact;
run;
Output 47.2.1: Results of the Wilcoxon TwoSample Test
Wilcoxon Scores (Rank Sums) for Variable Time Classified by Variable Stim 
Stim 
N 
Sum of Scores 
Expected Under H0 
Std Dev Under H0 
Mean Score 
1 
13 
110.50 
130.0 
11.004784 
8.500 
2 
6 
79.50 
60.0 
11.004784 
13.250 
Average scores were used for ties. 
Wilcoxon TwoSample Test 
Statistic (S) 
79.5000 


Normal Approximation 

Z 
1.7265 
OneSided Pr > Z 
0.0421 
TwoSided Pr > Z 
0.0843 


t Approximation 

OneSided Pr > Z 
0.0507 
TwoSided Pr > Z 
0.1014 


Exact Test 

OneSided Pr >= S 
0.0527 
TwoSided Pr >= S  Mean 
0.1054 
Z includes a continuity correction of 0.5. 
KruskalWallis Test 
ChiSquare 
3.1398 
DF 
1 
Pr > ChiSquare 
0.0764 

Output 47.2.1 displays the results of the Wilcoxon twosample test.
The Wilcoxon statistic equals 79.50. Since this value is greater than
60.0, the expected value under the null hypothesis, PROC NPAR1WAY displays
the rightsided pvalues. The onesided exact pvalue equals 0.0527,
which is not significant at the 0.05 level. The normal
approximation yields a onesided pvalue of 0.0421, which is significant
at the 0.05 level. Thus, the normal approximation may result in
rejection of the null hypothesis, while the exact test may result
in acceptance.
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.