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]

st: Generating dummy variables based on two categories..


From   Mukund Chari <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Generating dummy variables based on two categories..
Date   Wed, 30 Jan 2013 20:16:28 +0000

Dear Stata-listers,

I am trying to generate dummy variables based on two variables with multiple categories in each.
The dummies need to represent each unique combination of the two variables.

UserID   Techlab               UserTechD1       UserTechD12     UserTechD13     UserTechD14     UserTechD15     UserTechD6                UserTechD7       UserTechD8       
                                                (Comb: 11)          (Comb: 21)          (Comb: 22)          (Comb: 23)          (Comb: 31)          (Comb: 32)                (Comb: 43)          (Comb: 51)          
1              1                              1                              0                              0                              0                              0                              0                              0                              0              
2              1                              0                              1                              0                              0                              0                              0                              0                              0
2              2                              0                              0                              1                              0                              0                              0                              0                              0
2              3                              0                              0                              0                              1                              0                              0                              0                              0
3              1                              0                              0                              0                              0                              1                              0                              0                              0
3              2                              0                              0                              0                              0                              0                              1                              0                              0
4              3                              0                              0                              0                              0                              0                              0                              1                              0
4              3                              0                              0                              0                              0                              0                              0                              1                              0
5              1                              0                              0                              0                              0                              0                              0                              0                              1

The tabulate: generate command uses only a single variable to create the dummies; not sure what to do when there are multiple variables.

Any help is most appreciated.

Best,
Mukund.



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