proc iml; /*------------------------------------------------------*/ /* The CHOOSE Module */ /* */ /* We consider all the possible choices of M objects */ /* from a set of M+N. There is a sequential way of */ /* ordering them. The module CHOOSE gives you the next */ /* choice when you supply a given selection and the */ /* parameters M and N. The vector VEC is input and */ /* consists of integers from 1 to M+N. Examples if you */ /* are choosing five objects from a set of 8: */ /* 1) Input mvec0=[1 2 3 5 7] and get mvec1=[1 2 3 5 8] */ /* 2) Input mvec0=[1 3 4 7 8] and get mvec1=[1 3 5 6 7] */ /* This module is used inside the module PERMTEST. */ /*------------------------------------------------------*/ start choose(vec,mvec0,m,n, mvec1); mvec1=mvec0; do place=m to 1 by -1; if mvec0[1,place](mn+1)/2); if test='VW' then score0=probit(mvec0/(mn+1)); if test='SAVAGE' then do; score0=j(1,m,.); do j = 1 to m; mj=mvec0[1,j]; score0[1,j]=sum(savvec[1,1:mj])-1; end; end; rankstat=sum(score0); if rankstat<=sumscore then pval[1,1]=pval[1,1]+1; if rankstat>=sumscore then pval[1,2]=pval[1,2]+1; pval[1,3]=2*min(pval[1,1],pval[1,2]); if i1 then pval[1,3]=1; reset noname; chead={"Lower-Tail" "Upper-Tail" "Two-Tail"}; print pval[colname=chead]; finish;