I am very new with Stata
I preform simple logistic regression and want to extract odds ratios and confidence intervals from r(table).
If I put each comment one by one in the prompt, the result is fine.
But several problems pop up when I try to write the same thing into the foreach loop in a do file. Please help me
I have tried to search online, but find nothing.
------------------------------------------------------------------------------------------------------------------------------
local x age50 sex bmi224
local y ckd60
local i=1
mat all=J(35,5,.)
foreach v of local x {
logistic `y' `v' if nonBnonC==1 /// (`y' is not put in the model)
matrix A =`r(table)' /// A is not found.
mat all[`i',1]= round(A[`i',1],0.001)
mat all[`i',2]=round(A[`i',5],0.001)
mat all[`i',3]=round(A[`i',6],0.001)
mat all[`i',4]=round( normal(-abs(A[`i',3]))*2,0.001)
local i=`i'+1
}
matrix rowname A=`x'
matrix colname A= "Odds Ratio" "Lower Limit" "Upper Limit" p
Comment