*! version 3.0.0 23oct1997 statalist program define sdtest version 5.0 local varlist "req ex max(1)" local exp "opt noprefix" local if "opt" local in "opt" local options "BY(string) Level(integer $S_level)" parse "`*'" tempvar touse mark `touse' `if' `in' if "`exp'"!="" { if "`by'"!="" { di in red "may not combine = and by()" exit 198 } capture confirm number `exp' if _rc == 0 { /* Do chi-squared test. */ _ttest one sdtesti `level' `touse' `varlist' `exp' exit } /* If here, do variance ratio test with 2 variables. */ _ttest two sdtesti `level' `touse' `varlist' `exp' exit } /* If here, do variance ratio test with by() variable. */ if "`by'"=="" { di in red "by() option required" exit 100 } confirm variable `by' local nbyvars : word count `by' if `nbyvars' > 1 { di in red "only variable allowed in by()" exit 103 } _ttest by sdtesti `level' `touse' `varlist' `by' end exit