HI everyone,
Fairly new to Stata so still have a lot of learning to do. Hope I can explain this well enough that I can get some help. I'm working with ICD 10 codes and trying to code for VBAC using the 4 codes in quotes below. The codes are in one of 25 fields named "dx1", "dx2", "dx3"....."dx25". I essentially need Stata to search through all the dx columns to find one or more of the codes and then create a new variable called "i_VBAC." If "yes" then create i_VBAC=1. If the codes do not match any of the below, then i_VBAC=0. I have tried the code below (that someone gave me to try) and keep getting an error of "invalid syntax." Can anyone help or point me in a direction to go next? Thank you!
gen i_VBAC = 0
forvalues i = 1/25 {
replace i_VBAC = 1 if regexm(dx`i', "O34219", "O3421", "O34311", "O34212")}
Fairly new to Stata so still have a lot of learning to do. Hope I can explain this well enough that I can get some help. I'm working with ICD 10 codes and trying to code for VBAC using the 4 codes in quotes below. The codes are in one of 25 fields named "dx1", "dx2", "dx3"....."dx25". I essentially need Stata to search through all the dx columns to find one or more of the codes and then create a new variable called "i_VBAC." If "yes" then create i_VBAC=1. If the codes do not match any of the below, then i_VBAC=0. I have tried the code below (that someone gave me to try) and keep getting an error of "invalid syntax." Can anyone help or point me in a direction to go next? Thank you!
gen i_VBAC = 0
forvalues i = 1/25 {
replace i_VBAC = 1 if regexm(dx`i', "O34219", "O3421", "O34311", "O34212")}
Comment