*! version 1.0.1 Fri Apr 8 10:45:47 CDT 1994 (STB20: sg25) program define xi_ei /* I. */ version 3.1 local orig "`1'" tempvar g on local vn = substr("`orig'",3,.) _crcunab `vn' local vn "$S_1" if "$X__in" != "" { parse "$X__in", parse(" ") local i 1 while "``i''"!="" { if "``i''"=="`vn'" { global S_1 : word `i' of $X__out exit } local i=`i'+1 } } qui egen `g' = group(`vn') qui summ `g' local ng = _result(6) local lowcode 1 local topcode `ng' local useuser 0 cap confirm string var `vn' if _rc { local isnumb "yes" cap assert `vn'==int(`vn') & `vn'<100 & `vn'>=0 if `vn'!=. if _rc==0 { qui summ `vn' local lowcode = _result(5) local topcode = _result(6) local useuser 1 } } xi_mkun `vn' `topcode' local svn "$S_1" /* user macro "x omit " */ if "${`vn'}"!="" { tempvar umark parse "${`vn'}", parse(" ") if "`1'"=="xi" & "`2'"=="omit" & "`3'"!="" { if "`isnumb'"=="yes" { capture confirm number `3' if _rc { di in red /* */ "global macro `vn' (${`vn'}) invalid;" _n /* */ "variable `vn' is numeric" exit 198 } gen byte `umark'= float(`vn')==float(`3') } else gen byte `umark'= `vn'=="`3'" capture assert `umark'==0 if _rc==0 { di in gr "(global macro `vn': ${`vn'}" _n /* */ " yet variable `vn' never equals `3'; macro ignored)" local umark } } } /* code for dropping first category */ if "`umark'"=="" & "$S_XIMODE"=="" { tempvar umark qui gen byte `umark'=(`g'==1) } local max 0 local jmax 0 local j 1 qui gen long `on'=. while `j'<=`ng' { /* obtain value */ qui replace `on'=cond(`g'==`j',_n,`on'[_n-1]) local value = `vn'[`on'[_N]] if `useuser' { local k `value' } else local k `j' qui gen byte `svn'`k' = `g'==`j' if `g'!=. label var `svn'`k' "`vn'==`value'" if "`umark'"=="" { qui count if `g'==`j' if _result(1)>`max' { local max = _result(1) local jmax `k' local dval "`value'" } } else { capture assert `umark' if `g'==`j' if _rc==0 { local jmax `k' local dval "`value'" } } local j=`j'+1 } if `useuser' { di in gr "`orig'" /* */ _col(23) "`svn'`lowcode'-`topcode'" /* */ _col(36) "(naturally coded; `svn'`jmax' omitted)" } else di in gr "`orig'" /* */ _col(23) "`svn'`lowcode'-`topcode'" /* */ _col(36) "(`svn'`jmax' for `vn'==`dval' omitted)" drop `svn'`jmax' capture list `svn'* in 1 if _rc { global S_1 "." } else global S_1 "`svn'*" global X__in "$X__in `vn'" global X__out "$X__out $S_1" end exit I.myvar means dummies for myvar, drop the most frequent I.myvar*this means continuous interaction (still drop most frequent) I.myvar*I.that means dummy interaction. I.myvar[what] means dummies for myvar, drop dummy for myvar==what I.myvar*thatvar means interaction of myvar and thatvar I.myvar[val]*thatvar[val] means drop corresponding. 12345678 I12345_# I1234_## I1234###