Hello!
I am quite new to Stata and I'm trying to run a mixed model for the different levels of multiple variables in order to do a forest plot (using comand forestplot). So I want to prepare an excel sheet that fits the appropiate format needed in foresplot. I have already figured out how to get all the data I need from each model with this code (it may be a bit rudimentary, but it works!):
This gives me the format I want. Both, sex and age have value labels assigned, and I would like to print each value label instead of the level, I'm guessing I have to change something here
, since I would like for instance sex-Female while now it prints sex-1. Does anybody have any insight on how to do this?
Thank you so much in advance!
I am quite new to Stata and I'm trying to run a mixed model for the different levels of multiple variables in order to do a forest plot (using comand forestplot). So I want to prepare an excel sheet that fits the appropiate format needed in foresplot. I have already figured out how to get all the data I need from each model with this code (it may be a bit rudimentary, but it works!):
Code:
putexcel set results, sheet("name") modify putexcel A1 = ("_OVER") B1 = ("_LEVEL") C1 = ("_LABELS") D1= ("_ES") E1=("_seES") F1=("_LCI") G1=("_UCI") H1 = ("_USE") I1 = (" Variable levels") loc x = 2 foreach i in sex age { // All the variables for which I want to run my model, only showin two of them. quietly levelsof `i', local(levels`i') foreach z of local levels`i'{ quietly mixed FinalScore i.Treatment Baselinescore if `i' == `z' || IDS_T0: // I run the model for each level within each variable matrix rtable = r(table)' matrix r_table = rtable[2,1..2],rtable[2,5..6] quietly putexcel D`x' = matrix(r_table) I`x' = "`i'-`z'" loc x = `x' + 1 } }
Code:
quietly putexcel D`x' = matrix(r_table) I`x' = "`i'-`z'"
Thank you so much in advance!
Comment