Statalist


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

st: Workflow to combine dummy variables?


From   John A Stefanic <stefanic@Colorado.EDU>
To   statalist@hsphsun2.harvard.edu
Subject   st: Workflow to combine dummy variables?
Date   Tue, 20 Nov 2007 22:09:28 -0700

Hello all! First time caller. I'm having a lot of trouble combining dummy variables and creating a new variable where I count dummy variables.

So, I have a dataset (GSS) with variables SPOUSE1, CHILD1, SPOUSE2, CHILD2, SPOUSE3, CHILD3, indicating if person 1, 2, and 3 are a spouse or child. In each variable, 1 == Mentioned, 2 == Not Mentioned.

Since both SPOUSE1 and CHILD1 are kin, I want to recode them into a new variable, KIN1, if either SPOUSE1 or CHILD1 == 1. So I tried:

recode SPOUSE1 SPOUSE2 CHILD1 CHILD2 (2 = 0) (1 = 1) (.a = .a) (.c = .c), pre(RE)

Then, I did this:

generate int KIN1 = RESPOUSE1 + RECHILD1

This works fine, I get a new variable KIN1, with values 1 (person is kin) or 0 (person not kin). But, now I want to make another new variable, NUMKIN, indicating the sum of variables KIN1, KIN2, and KIN3.

So, I did this:

generate int NUMKIN == KIN1 + KIN2 + KIN3

But, my results exclude a number of cases as missing data. If the case is not a "1" for KIN3, it is excluded! Is there something I can do to change my workflow to make this process easier? How does one combine dummy variables in STATA?

Thanks!
*
* 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