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?
Plotting a histogramHi I am working with village wise consumption data and I need to generate histograms for the consum…
Testing coefficient equality across different regressions (bootstrap)Dear All, Suppose that I estimate the following two regressions (please ssc install ivreghdfe. In ad…
Multilevel modelling within Time Series Analysis of Cross-Sectional dataHi, I'm trying to model person within household within a Time Series of Cross-sectional Panel data.…
FormatHello All, I have a difficulty formating my year variable in my data set. The data set is a huge ta…
Using NetCDF data in StataHello, I am trying to use data stored in the NetCDF format (.nc file extension) for a project I am …
Subscribe to:
Post Comments (Atom)
0 Response to Is there an 'or' function when coding variables?
Post a Comment