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/