```
ODS OUTPUT WilcoxonScores=wlx(drop=variable);
ODS EXCLUDE wilcoxonScores;
PROC NPAR1WAY data=full wilcoxon;
CLASS year; VAR q1;
TITLE1 'Nonparametric Analysis: Kruskall Wallis Test';
run;
PROC PRINT DATA=wlx NOObs ;
run;
* macro var k == number of groups;
DATA _null_ ; SET wlx nobs=nobs; CALL SYMPUT("k",LEFT(nobs)); run;
%put &k.;
PROC TRANSPOSE DATA =wlx OUT=cnts(drop=_name_ _label_) prefix=_n; var n;
ID class; run;
PROC TRANSPOSE DATA =wlx OUT=mns(drop=_name_ _label_) prefix=_mn; var
meanscore; ID class; run;
proc print data=cnts; RUN;
proc print data=mns; RUN;
%LET alpha=.05; * familywise pvalue ;
/*Below, I just substituted Z for the number that made the critical value
equal to the absolute difference, then looked that number up on a normal
distribution table. This number provides the unadjusted p-value that you
compare with the Bonferroni alpha level of significance. */
/*Next you can multiply the unadjusted p-value by k, to determine the Bonferrroni
adjusted p-value for the wilcoxon multitest*/
DATA results; SET cnts; SET mns; DROP nn _n1-_n&k. _mn1-_mn&k.;
LENGTH reject $2; RETAIN reject ' ';
LABEL compare='Critical Value' abs_diff='Absolute Difference in Mean
Ranks';
c= ((&k.*(&k.-1))/2); * number of pairwise tests;
z = PROBIT( (1- ((&alpha./2)/ c) ) ); * multiplier ;
nn=SUM(of _n1-_n&k.); * total number of observations ;
ARRAY nc{&k.} _n1 - _n&k.;
ARRAY mn{&k.} _mn1 - _mn&k.;
DO i = 1 to (&k.-1);
DO j = (i+1) TO &k.;
sc1 = mn{i}; sc2 = mn{j};
ABS_diff = abs(sc1 - sc2);
compare = z * SQRT( nn*(nn+1)/12 * ((1/nc{i}) + (1/nc{j})));
IF abs_diff > compare then reject='**'; * the ** marker is to denote
any significant differences ;
OUTPUT results;
reject=' '; * reset marker to missing ;
END;
END;
RUN;
proc print data=results NOobs label;
var i j sc1 sc2 ABS_diff compare reject z;
FORMAT abs_diff 6.3 compare 6.2;
run;
```