I am coding a binary variable (done) to denote if a diagnostic test was done, 1=yes, 0=no.
I want it to be coded 1 only if it meets a set of conditions. In all cases diagnostics must =1, but the second condition varies.
Across each row if diagnostics==1 & test1==1, or diagnostics==1 & test2==1. or diagnostics==1 & test3==1 etc....then I want it to be coded 1.
At the moment I have:
replace done=1 if diagnostics==1 & test1==1 | test2==1 | test3==1
but this seems to be coding done=1 if any of those conditions have been met. If diagnostics==0 & test1==1 then I still want the code to be 0, at the moment it is being coded as 1.
How do I do this?
Thank you
0 Response to Is there an 'or' function when coding variables?
Post a Comment