Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Data management problem: unique combinations


From   "riteshm" <[email protected]>
To   <[email protected]>
Subject   RE: st: Data management problem: unique combinations
Date   Wed, 19 Jan 2005 19:53:35 -0800

Thanks very much! 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Daniel Egan
Sent: Wednesday, January 19, 2005 3:04 PM
To: [email protected]
Subject: Re: st: Data management problem: unique combinations

Ritesh Asked:

> I need help with a data management problem. What is an efficient way
of
> creating a categorical variable which consists of all unique
> combinations of a series of indicators variables?
> 
> For example, I have a data set with five binary variables: var1, var2,
> var3, var4 and var5. A new variable is needed in which the categories
> represent all possible unique combinations of var1-var5.

this is the vocation of -egen...group()-

to use the resulting variable as a categorical, combine it with -xi-

for example:
egen combo=group(var1 var2 var3 var4 var5)
xi i.combo

Also see  -fillin- if you would like to create all possible
combinations, not just the ones that occur within the data.

Cheers, 
Dan
*
*   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/

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index