/***************************************************** MACRO: WALSH CREATES SORTED WALSH AVERAGES FOR USE IN COMPUTING CONFIDENCE INTERVALS FOR POP MEDIAN INPUT: datain, name of data set vfir, name of variable containing data OUTPUT: Sorted Walsh averages to output data set dataout *****************************************************/ *options symbolgen mlogic mprint; %macro walsh(datain,vfir,dataout); proc iml; use &datain; read all var{&vfir} into y; nobs=nrow(y); nw=nobs*(nobs+1)/2; *print nobs nw; w=j(nw,1,0); index=0; do i=1 to nobs; do j=1 to i; index=index+1; w[index]=(y[i]+y[j])/2; end; end; *print w; varnames={w}; create &dataout from w [colname=varnames]; append from w; quit; proc sort data=&dataout; by w; run; %mend walsh; * Test it; data hlex3_1; input y @@; cards; -8 3 -9 -4 -7 -6 -5 2 -1 ; run; %walsh(hlex3_1,y,test_out); proc print data=test_out;run;