Hello,
I was hoping someone could provide me with some code to create a variable based on values of a list of other variables. I have 25 variables (labeled dx_icd10_*) and want to create a binary variable that equals 1 when ANY of these variables equals ANY of the following values: E10.*, E11.*, E08.*, E09*, E13.*
I know that I could do this by creating a very long string of "if" statements but am hoping for something more elegant than this. I have included a dataex example below.
Thank you!
Sarah
I was hoping someone could provide me with some code to create a variable based on values of a list of other variables. I have 25 variables (labeled dx_icd10_*) and want to create a binary variable that equals 1 when ANY of these variables equals ANY of the following values: E10.*, E11.*, E08.*, E09*, E13.*
I know that I could do this by creating a very long string of "if" statements but am hoping for something more elegant than this. I have included a dataex example below.
Thank you!
Sarah
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str35 dx_icd10_1 str28 dx_icd10_2 str21 dx_icd10_3 str28(dx_icd10_4 dx_icd10_5 dx_icd10_6) str23 dx_icd10_7 str20 dx_icd10_8 str14 dx_icd10_9 "E29.1" "R73.03" "" "" "" "" "" "" "" "E23.0" "R73.03" "N52.1" "" "" "" "" "" "" "E89.0" "E05.00" "R73.03" "E03.8" "" "" "" "" "" "R79.89" "" "" "" "" "" "" "" "" "R62.52" "Q23.4" "Z68.51" "" "" "" "" "" "" "R62.52" "Z68.51" "" "" "" "" "" "" "" "R62.52" "Z68.51" "" "" "" "" "" "" "" "R73.03" "E16.1" "E34.9" "" "" "" "" "" "" "E03.8" "" "" "" "" "" "" "" "" "E10.65" "E27.1" "E06.3" "K31.84" "E78.00" "" "" "" "" "E10.65" "E27.1" "E06.3" "K31.84" "E78.00" "" "" "" "" "E11.9" "E78.5" "" "" "" "" "" "" "" "E11.9" "E78.5" "" "" "" "" "" "" "" "C73" "E89.0" "Z79.899" "" "" "" "" "" "" "E66.9" "E55.9" "E83.51" "E21.3" "Z98.84" "R20.2" "" "" "" "E03.1" "" "" "" "" "" "" "" "" "E03.1" "" "" "" "" "" "" "" "" "E03.1" "" "" "" "" "" "" "" "" "E03.1" "" "" "" "" "" "" "" "" "E03.1" "" "" "" "" "" "" "" "" "E03.1" "" "" "" "" "" "" "" "" "E03.1" "" "" "" "" "" "" "" "" "E03.1" "" "" "" "" "" "" "" "" "E03.1" "" "" "" "" "" "" "" "" "E03.1" "" "" "" "" "" "" "" "" "E03.1" "" "" "" "" "" "" "" "" "E06.3" "" "" "" "" "" "" "" "" "C73" "" "" "" "" "" "" "" "" "E04.2" "" "" "" "" "" "" "" "" "E11.42" "" "" "" "" "" "" "" "" "E11.22, N18.3" "E78.5" "E78.1" "E11.42" "I10" "R21" "" "" "" "E11.22, N18.3" "E78.5" "" "" "" "" "" "" "" "E21.0" "M85.852" "E03.9" "" "" "" "" "" "" "C73" "" "" "" "" "" "" "" "" "E28.2" "" "" "" "" "" "" "" "" "E11.65" "E03.9" "" "" "" "" "" "" "" "E06.3" "" "" "" "" "" "" "" "" "E10.65" "" "" "" "" "" "" "" "" "E03.9" "" "" "" "" "" "" "" "" "M81.8" "" "" "" "" "" "" "" "" "M81.8" "" "" "" "" "" "" "" "" "E05.90" "E05.00" "E04.2" "" "" "" "" "" "" "E05.00" "" "" "" "" "" "" "" "" "E05.00" "E05.90" "" "" "" "" "" "" "" "E25.9" "" "" "" "" "" "" "" "" "E25.0" "" "" "" "" "" "" "" "" "E05.20" "E05.90" "" "" "" "" "" "" "" "E21.5" "E55.9" "E11.29, R80.9" "I10" "E21.1" "" "" "" "" "E55.9" "E05.20" "E05.90" "M81.0" "" "" "" "" "" "E25.0" "" "" "" "" "" "" "" "" "E10.65" "" "" "" "" "" "" "" "" "Q89.2" "J39.8" "Z86.39" "O09.93" "" "" "" "" "" "E10.65" "" "" "" "" "" "" "" "" "E10.65" "" "" "" "" "" "" "" "" "Q89.2" "Z3A.23" "" "" "" "" "" "" "" "E89.0" "" "" "" "" "" "" "" "" "E89.0" "E05.00" "" "" "" "" "" "" "" "E87.6" "D35.01" "" "" "" "" "" "" "" "E23.0" "" "" "" "" "" "" "" "" "E23.0" "" "" "" "" "" "" "" "" "E03.9" "N64.3" "R35.0" "" "" "" "" "" "" "E03.9" "" "" "" "" "" "" "" "" "E23.0" "" "" "" "" "" "" "" "" "E10.65" "" "" "" "" "" "" "" "" "E10.65" "R76.8" "" "" "" "" "" "" "" "E10.65" "" "" "" "" "" "" "" "" "E05.90" "E05.00" "" "" "" "" "" "" "" "E05.00" "R03.0" "" "" "" "" "" "" "" "E05.00" "" "" "" "" "" "" "" "" "E83.52" "E21.0" "E55.9" "M85.80" "" "" "" "" "" "E21.0" "E83.52" "M85.852" "E67.3" "" "" "" "" "" "E10.65" "" "" "" "" "" "" "" "" "E10.65" "" "" "" "" "" "" "" "" "E10.65" "" "" "" "" "" "" "" "" "E66.9, Z68.31" "E88.81" "I10" "R53.83" "" "" "" "" "" "E10.9" "E06.3" "Z96.41" "" "" "" "" "" "" "E10.65" "" "" "" "" "" "" "" "" "E10.65" "" "" "" "" "" "" "" "" "E10.65" "Z96.41" "E03.8, E06.3" "" "" "" "" "" "" "E10.9" "Z96.41" "E03.8, E06.3" "" "" "" "" "" "" "P70.2" "R73.9" "" "" "" "" "" "" "" "E16.1" "" "" "" "" "" "" "" "" "P70.2" "R73.9" "" "" "" "" "" "" "" "P70.2" "R73.9" "" "" "" "" "" "" "" "Q98.4" "E78.00" "" "" "" "" "" "" "" "E10.9" "E03.9" "" "" "" "" "" "" "" "Q98.4" "E78.00" "" "" "" "" "" "" "" "E10.9" "E03.9" "" "" "" "" "" "" "" "E10.9" "" "" "" "" "" "" "" "" "R53.83" "" "" "" "" "" "" "" "" "R53.83" "R63.1" "" "" "" "" "" "" "" "C73" "" "" "" "" "" "" "" "" "M81.8" "Q87.89" "Z98.1" "" "" "" "" "" "" "D35.2" "G43.819" "" "" "" "" "" "" "" "R63.5" "R79.89" "N92.6" "D35.2" "" "" "" "" "" "E10.649" "Z96.41" "K90.0" "E10.65" "E16.2" "" "" "" "" "E10.9" "" "" "" "" "" "" "" "" "E10.9" "" "" "" "" "" "" "" "" "E10.9" "" "" "" "" "" "" "" "" "E10.9" "" "" "" "" "" "" "" "" end
Comment