Hello,
I have a foreach loop where I loop through all Id´s I have. Each Id has several entries, I would like to fetch specific values for each Id. Fx I would like to fetch the Id´s Cemented variable. I would know how to do that in Python but I have no Idea how to do that in Stata. I have the following code below:
I have a foreach loop where I loop through all Id´s I have. Each Id has several entries, I would like to fetch specific values for each Id. Fx I would like to fetch the Id´s Cemented variable. I would know how to do that in Python but I have no Idea how to do that in Stata. I have the following code below:
Code:
levelsof ID, local(ids) foreach id of local ids { // new paragraph putdocx paragraph // some general information about the patient // id putdocx text ("ID: `id', "), bold // side local side = Side putdocx text ("Side: `side', ") // prosthesis local prosthesis = TibiaType putdocx text ("Tibia Type: `prosthesis', ") // cemented local cemented = Cemented putdocx text ("Cemented: `cemented'.") // migration status local migration = migration_status putdocx text ("Migration status: `migration'.") twoway (scatter Ty_median Phase if ID == "`id'", c(L)) (line ref Phase if ID == "`id'"), title("Migration status: `migration_status'") graph export "ty_median_vs_ref_`id'.png", replace putdocx image "ty_median_vs_ref_`id'.png" }