Thank you!
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Cox
Sent: Wednesday, January 19, 2005 3:06 PM
To: [email protected]
Subject: st: RE: Data management problem: unique combinations
-egen, group()- maps all combinations 
that occur in your data to integers 1 up. 
If you want all possible combinations 
to be coded systematically, you need 
some binary representation. Assuming
that -var1- to -var5- are coded 0 or 
1 this could be 
gen comb = 16 * var1 + 8 * var2 + 4 * var3 + 2 * var4 + var5 
or something producing a corresponding string. 
Often the latter is more transparent. There is a 
corresponding -egen- function -base()- in the 
package -egenmore- on SSC. 
Nick 
[email protected] 
riteshm
> 
> 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.
*
*   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/