Bookmark and Share

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]

Re: st: Create a dummy variable meeting 2 conditions


From   Steve Samuels <sjsamuels@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Create a dummy variable meeting 2 conditions
Date   Mon, 24 Feb 2014 17:37:12 -0500

Billy has answered your question, but I want to point out that you are
not following the very strong request in the Statalist FAQ to use your
full real name when posting.

Regards,

Steve Samuels
sjsamuels@gmail.com

On Feb 24, 2014, at 4:43 PM, Li <lsj555@gmail.com> wrote:

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/

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index