************************************************************************ * CIPOISS: A SAS macro for exact Poisson confidence limits * * * * This SAS macro calculates the exact confidence limits for * * a Poisson count. * * * * Algorithm: Daly, Leslie, "Simple SAS macros for the * * calculation of exact binomial and Poisson * * Confidence limits" * * Comput Biol Med, 22(5):351-361, 1992. * * * * Leslie Daly, * Lecturer in Medical Statistics, * Department of Public Health Medicine and Epidemioilogy, * University College Dublin, * Earlsfort Terrace, Dublin 2, IRELAND * * Email: LDALY@IVEAGH.UCD.IE * * Functions called: LOG * * GAMINV * * * * Usage: %CIPOISS(cl,x,ll,lu) * * * * Input parameters: cl - confidence level as a proportion * * (e.g. 0.95) * * x - observed number of events * * * * Output parameters: ll - Lower confidence limit * * lu - Upper confidence limit * * * * Usage notes: Missing values for the output parameters are * * generated if (1) X is less than zero, or if * * (2) CL is not between 0.0 and 1.0. * * * ************************************************************************; %macro cipoiss(cl,x,ll,lu); if (&x) lt 0 or not(0 lt (&cl) lt 1) then do; &ll = .; &lu = .; end; else do; if (&x) ne 0 then do; &ll = gaminv((1 - (&cl))/2, (&x)); &lu = gaminv((1 + (&cl))/2, (&x) + 1); end; else if (&x) eq 0 then do; &lu = -log(1 - (&cl)); &ll = 0; end; end; %mend; /* * Sample program follows: *; data tempa; cl = .95; input x ; %cipoiss(cl,x,ll,lu); width = lu - ll; cards; 69 15 8 70 15 4 98 79 run; proc print data=tempa; run; */