*;
rank the data ;
in case not ranked ;
proc sort data=a; by subject;
proc rank data=a out=b;
by subject;
var rank;
ranks rankresp;
run;
find total number of
subjects ;
proc transpose data=a
out=numsub;
by subject;
var rank;
run;
data numsub;
set numsub end=eof;
if eof then do;
totnum = n;
output;
end;
**** find the sum of the ranks
for each cond
proc sort data=b; by cond;
proc means data=b noprint;
by cond;
var rankresp;
output out=rank sum=sumrank;
run;
find the total number of
groups ;
%global totgp;
data null;
if 0 then set rank
nobs=count;
call symput ('totgp', left
(put (count, 8.)));
stop; run;
data rank;
if n = 1 then do;
set numsub;
end;
set rank;
*****;
** carry out comparisons for
each pair of groups *;
*****;
Appendix 383