*! Version 1.0.1 [STB-51: sbe30] program define oddsrci *! CIs for the odds ratio defined by two Boolean conditions *! Syntax: . oddsrci [fweight] [if] [in], C1(1st Boolean condition) *! C2(2nd Boolean condition) [ LEVel(0.xx) *! TABopt(tab options) NONE ALL AGresti COrnf GArt WOolf ] * John R. Gleason (loesljrg@accucom.net) version 6.0 if "`1'" == "?" { which oddsrci exit } syntax [fweight] [if] [in] , C1(string asis) C2(string asis) /* */ [ TABopt(string asis) NONE * ] if `"`if'`in'"' != "" { di in gr "Select cases: " in ye `"`if' `in'"' } tempvar D1 D2 qui cap gen byte `D1' = `c1' `if' `in' if _rc { x `c1' } qui cap gen byte `D2' = `c2' `if' `in' if _rc { x `c2' } lab var `D1' "Cond. 1" lab var `D2' "Cond. 2" tempname Mat TF lab def `TF' 0 "False" 1 "True" lab val `D1' `TF' lab val `D2' `TF' di _col(4) in gr "Cond. 1:", in ye `"`c1'"' di _col(4) in gr "Cond. 2:", in ye `"`c2'"' tokenize `tabopt' local i 1 while "``i''" != "" { if index("nofreq", "``i''") { local `i' " " } local i = `i' + 1 } tab `D1' `D2' [`weight'`exp'], matcell(`Mat') `*' if !( (r(r)==2)*(r(c)==2)*("`none'"=="") ) { exit } if "`*'" != "" { di "" } local a = `Mat'[1,1] local b = `Mat'[1,2] local c = `Mat'[2,1] local d = `Mat'[2,2] oddsrcii `a' `b' `c' `d', notable `options' end program define x di in red `"Invalid condition: `*'"' error 499 end