I am trying to create a separate excel sheet for each id of a dataset with information specific to the patient. For example, I would like to put the language that the patient has indicated they speak into the excel sheet. I am able to specify this for an individual patient but would like to create a loop for each patient. I am not able to use an if statement for putexcel, so I have been trying a few other things but have not been successful. Any ideas of how I could specify that stata should put id specific information into the Excel sheet for that id?
levelsof clinic_id_confirm, local(id)
foreach val of local id {
putexcel set consentdocumentation_`val'.xlsx , replace
putexcel D4 = "Study Consent Documentation Form"
putexcel A6 = "Title: XXXXX"
putexcel A8 = "What language(s) do you understand?"
if clinic_id_confirm == `val' {
putexcel A9 = language_prefer_string
}
}
levelsof clinic_id_confirm, local(id)
foreach val of local id {
putexcel set consentdocumentation_`val'.xlsx , replace
putexcel D4 = "Study Consent Documentation Form"
putexcel A6 = "Title: XXXXX"
putexcel A8 = "What language(s) do you understand?"
if clinic_id_confirm == `val' {
putexcel A9 = language_prefer_string
}
}

Comment