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
Related Posts with Is there an 'or' function when coding variables?
displaying Odds Ratios and 95% Confidence Intervals in word using outregHi All I am rather new to Stata and have encountered some difficulty in generating a word documents…
Creating deciles/quintiles based on a certain group of observations by yearHello I have a panel data of all NYSE, AMEX and NASDAQ firms. I am trying to create size deciles ba…
Comparing models and profiles (including significance) using LPA (continous variables)Hello everyone, Thanks for all the helpful information on this site. I am trying to compare models…
Sort two variables simultaneouslyHi is it possible to sort two variables for example by id number and sex. So if I have the following…
Counting letters in Stata?Hello Maybe a weird question, but I can do Code: local i = 1 foreach x of numlist 1/10 { di `i'…
Subscribe to:
Post Comments (Atom)
0 Response to Is there an 'or' function when coding variables?
Post a Comment