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: Code to generate dummy variable from several categorical variables?


From   "DEBORAH L. HUANG" <[email protected]>
To   [email protected]
Subject   RE: st: Code to generate dummy variable from several categorical variables?
Date   Mon, 16 Jan 2012 16:46:25 -0800 (PST)

Thank you for input and to clarify what I'm trying to do:

I'm trying to generate a dummy variable with 4 indicators; the values of the indicators are to be determined by 3 other binary variables which are not mutually exclusive. If generating a categorical variable could be done more easily that would be fine. I've already tried generating a composite categorical variable but have recoding problems as A, B and C are not mutually exclusive.

For example, possible values for binary variables A, B and C as follows:

    A     B     C
1.  1     0     0
2.  1     1     0
3.  1     1     1
4.  0     1     0
5.  0     1     1
6.  0     0     1
7.  0     0     0

So I'd like to generate dummy variable abnlX, where
- abnlX1 includes all subjects where A=1
- abnlX2 includes all subjects where B=1
- abnlX3 includes all subjects where C=1

My difficulty is in figuring out how to code in order to re-categorize subjects #2, #3 and #5 into all the appropriate categories (e.g., subject #2 should count toward abnlX1 and abnlX2). Additionally, there are some missing values for any of the variables A, B or C (subject may be missing value for A but have values for B and C, etc.) but I would still like to be able to include the available values.

Hopefully my question makes more sense. Thank you!
Deborah

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


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