Hello,

I have a dataset with patient ids. Each patient is in the dataset multiple times and have multiple diagnosis. I would like to code out a new variable for specific codes so that I can retain those patients. The criteria will apply to any of the multiple diagnosis. The diagnoses are string variables and id is numerical. Below is my data example and the code I am trying to use but to no avail. I would prefer not to repeat the coding for each variable separately as in my regional dataset, I have 100 diagnoses and 75 codes. I appreciate your help.


----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte id str5(diag1 diag2 diag3 diag4 diag5)
 0 "22.3" "20"   "10"   "44"   "23.3"
 1 "33.3" "16.2" "16.2" "20.1" "14"  
 2 "20.1" "20.1" "33.3" "14.5" "16.2"
 3 "13.2" "17.9" "12.0" "13"   "12.0"
 4 "15"   "12.0" "13.2" "16.2" "33.3"
 5 "12"   "18.4" "14.5" "12.0" "16.2"
 6 "33.3" "10"   "16.2" "13.2" "10"  
 7 "19"   "33.3" "14.5" "10"   "20.1"
 8 "28.9" "14.5" "33.3" "16.2" "20.1"
 9 "13.2" "16.2" "14.5" "10"   "17"  
10 "13.2" "20.1" "16.2" "13.2" "13.2"
end
------------------ copy up to and including the previous line ------------------

[/CODE]
gen New=1 if diag1|diag2|diag3|diag4|diag5=="33.3"|"20.1" |"13.2"|"17"