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?
Generating total load variable using item weightHi all, I am using the short form of SLE (stressful life events), which is an extract of the Holmes…
Uncombining data points when graphing longitudinal data with profileplotHi there, I'm using the "profileplot" command to plot sales data (public expenditure, GBP per 1000 …
Format forest plot after ipdmetanHi, I am using David Fisher's ipdmetan available from ssc (ssc install ipdmetan) to plot an IPD met…
xtmixed difference between main model and postestimation (pwcompare) results (with and without interaction effect)Hi there - sorry if this is a very silly question, but I was a little confused. Simplifed code and m…
Merging two datasetsI have two datasets that needs to be merged. But one row in the main dataset is representing multipl…
Subscribe to:
Post Comments (Atom)
0 Response to Is there an 'or' function when coding variables?
Post a Comment