*! Version 1.0.1 (STB-52 sg119) program define propci *! CIs for the proportion of cases where a given condition is true *! Syntax: . propci [fweight] [if] [in], Cond(Boolean condition) *! [ Level(0.xx) NONE ALL ARcsin EWald EXact WAld WIlson ] * John R. Gleason (loesljrg@accucom.net) version 6.0 if "`1'" == "?" { which propci exit } syntax [fweight] [if] [in] , Cond(string asis) [ NONE * ] di "" if `"`if'`in'"' != "" { di in gr "Select cases: " in ye `"`if' `in'"' } tempvar D qui cap gen byte `D' = `cond' `if' `in' if _rc { di in red `"Invalid condition: `cond'"' error 499 } tempname Mat MR TF lab def `TF' 0 "False" 1 "True" lab val `D' `TF' lab var `D' "Condition" di _col(3) in gr "Condition :", in ye `"`cond'"' tab `D' [`weight'`exp'], matcell(`Mat') matrow(`MR') local N = r(N) if r(r) > 2 { di in red `"Not a Boolean condition: `cond'"' error 499 } local N1 = `N' - (`MR'[1,1]==0)*`Mat'[1,1] if !( (`N' > 0)*("`none'" == "") ) { exit } di " " propcii `N' `N1', `options' end