Hi everyone,
I am working on a large database. The database has up to 15 variables for diagnosis of the disease. They are called DX1, DX2, DX3, etc. I want to select my cases based on certain diagnosis (let's say the diagnosis code for my cases is 275). This is what I was doing:
generate MyCases=0
replace MyCases=1 if DX1=="275" | DX2="275" | DX3="275" | DX ..... | DX15="275"
I am kinda sure that there is a better and smarter way of selecting (replacing) the cases but I don't know how to do it. Also, I tried using the * after the variable as follows:
generate MyCases=0
replace MyCases=1 if DX*=="275"
but the above command gives me an error: DX ambiguous abbreviation
I appreciate if anyone knows a faster/more efficient way of doing this.
Thanks,
Reza
I am working on a large database. The database has up to 15 variables for diagnosis of the disease. They are called DX1, DX2, DX3, etc. I want to select my cases based on certain diagnosis (let's say the diagnosis code for my cases is 275). This is what I was doing:
generate MyCases=0
replace MyCases=1 if DX1=="275" | DX2="275" | DX3="275" | DX ..... | DX15="275"
I am kinda sure that there is a better and smarter way of selecting (replacing) the cases but I don't know how to do it. Also, I tried using the * after the variable as follows:
generate MyCases=0
replace MyCases=1 if DX*=="275"
but the above command gives me an error: DX ambiguous abbreviation
I appreciate if anyone knows a faster/more efficient way of doing this.
Thanks,
Reza
Comment