MACRO permute2 d1 d2 results # # approximate randomization for difference of two means when # data is in columns d1 and d2 # copyright 2005 Robert L. Raymond University of St Thomas. Free use for # teaching and noncommercial research-retain this notice in this and derivative works MCOLUMN d1 d2 results joined subs MCONSTANT nu1 nu2 NOECHO # LET nu1 = COUNT(d1) LET nu2 = COUNT(d2) STACK d1 d2 joined SET subs nu1(1) nu2(2) END # now subs contains nu1 ones followed by nu2 twos NOTE ...macro is running ... CALL permute joined subs results ECHO ENDMACRO MACRO permute d s results # MCOLUMN d s news new1 new2 results inp MCONSTANT reps ntotal k NOECHO # NOTE NOTE How many replications ? SET inp; FILE 'TERMINAL'; NOBS 1. LET reps = inp(1) LET ntotal = COUNT(d) # DO k = 1:reps SAMPLE ntotal s news COPY d new1; USE news = 1. COPY d new2; USE news = 2. LET results(k) = MEAN(new1) - MEAN(new2) ENDDO HISTOGRAM results; TITLE 'Differences of Means'. ECHO ENDMACRO