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: Generating dummy variables based on two categories..
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: Generating dummy variables based on two categories..
Date
Wed, 30 Jan 2013 20:23:18 +0000
See e.g. the thread starting at
http://www.stata.com/statalist/archive/2012-10/msg00532.html
and its references.
Usage suggestions:
1. Indicator variable is a much better term than dummy variable.
2. Distinct is a much better word than unique.
Nick
On Wed, Jan 30, 2013 at 8:16 PM, Mukund Chari <[email protected]> wrote:
> 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.
*
* 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/