Dear Stata users,

I am having trouble with exporting odds ratios, confidence intervals and p-values from 230 different logistic regressions using filewrite. Exporting estimated beta coefficients, confidence intervals, and p-values works fine, but I would rather report the exponentiated betas (odds ratios) and associated confidence intervals as well as p-values.

The code that works but gives me beta coefficients instead of exponentiated beta coefficients (odds ratios) and confidence intervals instead of exponentiated confidence intervals is given below. The question is how do I change the code below to provide the exponentiated betas (odds ratios), confidence intervals, and p-values?




foreach bp of varlist disease2 {

cd "\\my documents\data"

file open table2 using "mytable1.txt", replace write
file write table2 _tab _tab "not adjusted" _tab _tab "Multiple adjusted" _n
file write table2 "Variable" _tab "Beta1" _tab "P-value1" _tab "Beta2" _tab "P-value2" _n

foreach lipid of varlist lipid1-lipid230 {

quietly: logistic `bp' `lipid'
file write table2 "`lipid'" _tab (round(_b[`lipid'],0.001)) " (" (round(_b[`lipid']- invnormal(0.975)*_se[`lipid'],0.001)) ", " (round(_b[`lipid']+ invnormal(0.975)*_se[`lipid'],0.001)) ")" _tab (round(2*normal(-abs(_b[`lipid']/_se[`lipid']))),0.0000000001) _tab

quietly: logistic `bp' `lipid' age sex weight
file write table2 (round(_b[`lipid'],0.001)) " (" (round(_b[`lipid']- invnormal(0.975)*_se[`lipid'],0.001)) ", " (round(_b[`lipid']+ invnormal(0.975)*_se[`lipid'],0.001)) ")" _tab (round(2*normal(-abs(_b[`lipid']/_se[`lipid']))),0.00000000001) _n

}

file close table2
}


/// Sam