Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: dummy variable with overlapping if conditions


From   "Austin Nichols" <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: dummy variable with overlapping if conditions
Date   Tue, 26 Sep 2006 17:53:50 -0400

Or, allowing for missing values:

gen and = d1&d2 if !mi(d1, d2)
gen or = d1|d2 if !mi(d1, d2)
gen xor = cond(d1+d2==1, 1, 0) if !mi(d1, d2)

It's always a good idea to add the "if not missing" clause.

On 9/26/06, Kit Baum <baum@bc.edu> wrote:
It is useful to note that a binary variable of this sort is the
intersection of the sets defined by each dummy. Intersection of sets
in binary arithmetic is done by multiplying, or with the AND operator
(&). The union of sets -- true if either is true -- is done with the
OR operator (|). Stata does not contain an exclusive OR operator
(XOR), but one can readily be fashioned by adding the dummies:

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index