************************************************************************** ************************************************************************** THE FOLLOWING MACRO CAN BE USED TO COMPARE TWO SIRS AND IS CONSISTENT WITH THE METHODS USED BY NHSN FOR SUCH COMPARISONS. (AUGUST 2011) ************************************************************************** **************************************************************************; %MACRO BINOM(n1,d1,n2,d2); SIR1 = round((&N1 / &D1),.001) ; SIR2 = round((&N2 / &D2),.001) ; MAX_SIR = max(SIR1,SIR2); if max_sir = SIR1 or sir1 = sir2 then do; K = &N1 ; /* # successes */ N_TRLS = &N1 + &N2 ; /* # trials */ OBS_PCT = &N1 / n_trls; EXP_PCT = &D1 / (&D1 + &D2); /* success probability */ EFF_BELOW = floor( 2*(n_trls * exp_pct) - k); /* lower effect */ if eff_below < 0 then EFF_BELOW = 0; end; else do; K = &N2 ; N_TRLS = &N1 + &N2 ; OBS_PCT = &N2 / n_trls ; EXP_PCT = &D2 / (&D1 + &D2); EFF_BELOW = floor( 2*(n_trls * exp_pct) - k); if eff_below < 0 then EFF_BELOW = 0; end; TAIL1_PV = 1 - probbnml(exp_pct, n_trls, k-1 ); /* 1-tailed p-value */ TAIL2_PV = probbnml(exp_pct,n_trls, eff_below) + tail1_pv ; /* 2-tailed p-value */ if sir1 = sir2 then TAIL2_PV = 1.0; CI_LL = round(betainv(.025,k,n_trls-k+1)*n_trls); CI_UL = round(betainv(.975,k+1,n_trls-k)*n_trls); run; %MEND binom;