program define ndbdifference
version 9.0
syntax varlist [if] [in] ,by(varname) [seed(real -1) Reverse reps(real
100)]
marksample touse, novarlist
if "`seed'" != "-1" {
set seed `seed'
}
foreach var of varlist `varlist' {
preserve
qui keep if `touse'
keep `var' `by'
qui keep if !mi(`var',`by')
bootstrap `"`var'_b"'=r(dif), ///
reps(`reps') nowarn nodots nolegend title(Difference between `by'
categories) ///
: difference `var',by(`by') `reverse'
restore
}
end
However, when I add -bca- to this line:
bca : difference `var',by(`by') `reverse'
The Stata program crashes with this error:
- if `"`bca'"' != "" {
= if `"bca"' != "" {
- forvalues i = 1/`K' {
= forvalues i = 1/1 {
- local name : word `i' of `names'
= local name : word 1 of sex_b
- local exp_list `exp_list' `name'=(`exp`i'')
= local exp_list `"sex_b"' =r(dif) sex_b=(r(dif))
invalid syntax
I don't understand this error, as I am not sure what is correct. However,
if I charge the bootstrap line to:
bootstrap `var'_b=r(dif), ///
The program runs correctly until I add -bca- again.
This time it gives the following error:
= di as err "name sex_b already specified"
name sex_b already specified
in the section for bca.
I wonder if anyone can point me in the right direction toward understanding
this error.
Thanks,
Fred
Fred Wolfe
National Data Bank for Rheumatic Diseases
Wichita, Kansas
Tel (316) 263-2125 Fax (316) 263-0761 [email protected]