Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Create a dummy variable meeting 2 conditions
From
Li <[email protected]>
To
[email protected]
Subject
st: Create a dummy variable meeting 2 conditions
Date
Mon, 24 Feb 2014 16:43:48 -0500
Dear Statalist members,
I have a question with regard to create a Dummy variable from two
variables. The coding of the two existing variables are as follows:
Var1: ( 1=smoked over 100 cigars lifetime ; 2 = Not smoked 100
cigars lifetime; 3= don't know; 99=missing).
Var2: (1=currently smoke every day; 2=currently smoke some days;
3=not smoking; 4=refuse to answer; 99=missing).
The new dummy variable I want to create needs to satisfy two
conditions: smoked over 100 cigars lifetime and currently smoking
everyday or some days, i.e.
New variable 1=current smoker (if Var1=1 & Var2=1 or 2);
0=nonsmoker;
. = Missing, don't know and refuse to
answer in Var1, Var2).
I know it is straightforward to use the "gen" in Stata to meet one
condition. I would appreciate if anyone shares how to incorporate the
conditions as above to make a new variable.
Thank you very much.
Jeff
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/