**********
g byte STH=1 if Hook==1 | Asca==1| Trich==1
replace STH=2 if Hook==2 & Asca==2 & Trich==2
**********
Careful, if neither the first nor the second case is true, STH goes to
missing. If you want it to go to zero, say
**********
g byte STH = Hook==1 | Asca==1| Trich==1
************
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
[email protected]
Sent: Wednesday, August 13, 2008 2:23 PM
To: [email protected]
Subject: st: generating a new variable from 3 binary variables
Dear all,
I am a new STATA user. I recently worked with SAS in the past. I am working
with 3 variables, all of which are binary (1 or 2). I am having some
complications generating a new variable, called STH (also binary). STH needs
to equal 1 if the variables HOOK, ASCA or TRICH=1. Any combination will do
as long as one of the 3 variables is equal to 1. In addition, STH needs to
equal 2 when HOOK, ASCA and TRICH=2. No combinations are permitted.
Any help on this would be greatly appreciated.
Layla
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/