*! version 4.0.0 PR 27Oct95. program define contrasi /* contrast in oneway anova, immediate */ version 4.0 parse "`*'", parse(",\ ") local r 1 local c 1 local cols . while ("`1'"!="" & "`1'"!=",") { if "`1'"=="\" { local r = `r' + 1 if `cols'==. { if (`c'<=2) { di in red "too few columns" exit 198 } local cols `c' } else { if (`c'!=`cols') { error 198 } } local c 1 } else { if `c'==1 { conf integer num `1' if `1'<0 { error 411 } } else { if "`1'"=="." { local 1 . } else conf num `1' } local n`r'`c' `1' local c = `c' + 1 } mac shift } if (`c'!=`cols') { error 198 } local cols = `cols' - 1 if `cols'<3 | `cols'>5 { di in red "too few or too many columns" error 198 } local nc = `r' local options "TRend *" parse "`*'" if "`trend'"!="" & `cols'==4 { di in bl "[trend not allowed in this context, ignored]" } preserve quietly { drop _all set obs `nc' gen long n = . gen mean = . gen sd = . gen coeff = . local r 1 while (`r'<=`nc') { local c 1 while (`c'<=`cols') { local v = `n`r'`c'' if `c'==1 { replace n = `v' in `r' } else if `c'==2 { replace mean = `v' in `r' } else if `c'==3 { replace sd = `v' in `r' } else if `c'==4 { replace coeff = `v' in `r' } local c = `c' + 1 } if `cols'==3 { replace coeff = `r' in `r' } local r = `r' + 1 } } /* Contrast evaluation. */ aov1cont n mean sd, coeffs(coeff) `options' end