MACRO CompProp nreps n1 n2 phat obsdiff Mconstant nreps n1 n2 phat obsdiff Count Pvalue I Mcolumn x1 phat1 x2 phat2 diff x Random nreps x1; Binomial n1 phat. Let phat1 = x1 / n1 Random nreps x2; Binomial n2 phat. Let phat2 = x2 / n2 Let diff = phat1-phat2 Sort diff diff; By diff. Let Count = 0 DO I = 1:nreps IF abs(diff(I)) GE obsdiff Let Count = Count +1 ENDIF ENDDO Let Pvalue=Count/nreps Print Pvalue Stem-and-Leaf diff. Histogram diff; Percent; CutPoint -1:1/.1; Bar; Type 1; Color 3; Title "Resampling Distribution"; Title "Difference in 2 proportions"; Minimum 1 -1; Maximum 1 1; ScFrame; ScAnnotation; Axis 1; Label "Difference in Proportions"; Axis 2; Tick 1; NMajor 5; NMinor 4; Tick 2; NMajor 6; NMinor 4. ENDMACRO