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

st: RE: again dummies


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: again dummies
Date   Sun, 7 Mar 2004 16:39:04 -0000

This is like taking the train from Manchester 
to Liverpool and then back again when you 
could stay in Manchester.  

Suppose you have something like a variable 
-myprime-, taking values 1, 2, 3, 5, 7. 

You could do this 

tab myprime, gen(myprime) 

producing dummies -myprime1- to -myprime5-, 
and then 

gen Prime = . 
forval j = 1/5 { 
	replace Prime = `j' if myprime`j' == 1 
} 

but you could just do this 

egen Prime = group(myprime) 

In other words, to map a variable to 
integers 1 up, just use -egen, group()- directly. 

Nick 
[email protected] 

Tumur Gunchinmaa

> How to join several dummies (dum1-dum5) into one variable giving 
> it values from 1-5 (according to dummies).

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