*! version 1.0.0 20 January 1994 RG sg43: STB-28 program define modt version 3.1 * if var1=var2 then var1 should be control group * if using "by()", then lower category should be control group local exp "opt noprefix" local if "opt" local in "opt" local options "By(string)" local varlist "req ex max(1)" parse "`*'" if "`exp'"!="" { if "`by'"!="" { di in red "may not combine = and by()" exit 198 } confirm var `exp' quietly sum `varlist' `if' `in' local n1 = _result(1) local u1 = _result(3) local s1 = sqrt(_result(4)) quietly sum `exp' `if' `in' local n2 = _result(1) local u2 = _result(3) local s2 = sqrt(_result(4)) if `s1'==. { error 2001 } modti `n1' `u1' `s1' `n2' `u2' exit } confirm var `by' quietly tab `by' `if' `in' if _result(2)!=2 { di in red "`by' takes on " _result(2) " values, not 2" exit 450 } tempvar M TOUSE quietly gen byte `TOUSE' = 1 `if' `in' sort `by' `TOUSE' quietly by `by' `TOUSE': gen byte `M'=cond(_n==1,1,.) if `TOUSE'==1 sort `M' `by' quietly sum `varlist' if `by'==`by'[1] & `TOUSE'==1 local n1 = _result(1) local u1 = _result(3) local s1 = sqrt(_result(4)) quietly sum `varlist' if `by'==`by'[2] & `TOUSE'==1 local n2 = _result(1) local u2 = _result(3) if `s1'==. { error 2001 } modti `n1' `u1' `s1' `n2' `u2' end