*! version 1.0.1 Fri Apr 8 10:47:15 CDT 1994 (STB20: sg25) program define xi_eii version 3.1 local orig "`1'" local ichar "`2'" local lstar = index("`orig'","`ichar'") local part1 = substr("`orig'",1,`lstar'-1) local part2 = substr("`orig'",`lstar'+1,.) if upper(substr("`part2'",1,2))!="I." { xi_eic `orig' "`ichar'" exit } else if "`ichar'"!="*" { di in red "I.xxx|I.yyy not allowed" exit 198 } xi_ei `part1' local res1 "$S_1" xi_ei `part2' local res2 "$S_1" if "`res1'"=="." | "`res2'"=="." { di in gr "`orig'" _col(36) "(requires no interaction terms)" exit } _crcunab `res1' local uab1 "$S_1" parse "`uab1'", parse(" ") local len1 0 while "`1'"!="" { if length("`1'")>`len1' { local len1 = length("`1'") } mac shift } _crcunab `res2' local uab2 "$S_1" parse "`uab2'", parse(" ") local len2 0 while "`1'"!="" { if length("`1'")>`len2' { local len2 = length("`1'") } mac shift } local len1 = `len1'-length("`res1'") + 1 local len2 = `len2'-length("`res2'") + 1 local len = `len1'+`len2' local c1 = substr("`res1'",2,1) local c2 = substr("`res2'",2,1) if `len'==2 { local stub "I`c1'X`c2'_" } else if `len'==3 { local stub "I`c1'`c2'_" } else if `len'==4 { local stub "I`c1'`c2'" } else { di in red "syserr: length |`len'| not right" exit 198 } xi_mkun2 `stub' local stub "$S_1" parse "`uab2'", parse(" ") local i 1 local a : word `i' of `uab1' while "`a'"!="" { local num1 = substr("`a'",length("`res1'"),.) local lbl1 : variable label `a' local j 1 while "``j''"!="" { local num2 = substr("``j''",length("`res2'"),.) qui gen byte `stub'`num1'_`num2' = `a'*``j'' local lbl2 : variable label ``j'' label var `stub'`num1'_`num2' "`lbl1' & `lbl2'" local j=`j'+1 } local i=`i'+1 local a: word `i' of `uab1' } global S_1 "`res1' `res2' `stub'*" di in gr "`orig'" _col(23) "`stub'#-#" /* */ _col(36) "(coded as above)" end exit 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 I123_#x# I12##x## For I.name*I.name We try: 12345 IrXr_ e.g., IrXr_#_# for two 1-digit numbers Irr_ e.g., Irr_#_## or Irr_##_# for 1 and 2 digit numbers Irr e.g., Irr##_## for two 2-digit numbers For I.name*name Irr_# I.abc*I.def IrXr_ we try, then shorten to Irr_ I12345_# I1234_## I1234###