I can't see why the following syntax generates a Stata error message in line 65 ("factor-variable operators not allowed") if I run it as a .do-file. But if I only select lines 37 ("// Ethnicity:") until 68 ("log off") it runs without error:
I'm probably overlooking something, but I can't see what it is.
Code:
/* Stata error 101 in row 65: */
clear all
version 9
global outp "/datadisk/Projekte/CCCC_Review/"
cap log close
log using "${outp}rean_tab_17-9.smcl", replace
// Reanalysis Table 17.19 (p. 316)
* ------------------------------------------------------------------------------
// Gender:
clear
input female exposure n
0 0 296
0 1 58
1 0 304
1 1 52
end
lab def female 0 "male" 1 "female"
lab val female female
lab var female "Gender"
lab def exposure 0 "low" 1 "high"
lab val exposure exposure
lab var exposure "Exposure"
expand n
tab2 female exposure, col chi2
tab2 female exposure, row chi2
log off
* ------------------------------------------------------------------------------
// Ethnicity:
clear
input ethnicity exposure n
0 0 495
0 1 94
1 0 68
1 1 4
2 0 33
2 1 10
3 0 4
3 1 2
end
lab def ethnicity 0 "White" 1 "Asian" 2 "mixed" 3 "Black"
lab val ethnicity ethnicity
lab var ethnicity "ethnicity"
lab def exposure 0 "low" 1 "high"
lab val exposure exposure
lab var exposure "Exposure"
expand n
log on
tab2 ethnicity exposure, col chi2
tab2 ethnicity exposure, row chi2
qui logistic exposure i.ethnicity, or
margins ethnicity, pwcompare(pv) mcompare(sidak)
log off

Comment