Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Creating a new variable by combining several


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Creating a new variable by combining several
Date   Tue, 5 Feb 2008 22:16:01 -0000

Good. The generalisation to other sets of dummies should be clear. If
there are twenty dummies, a loop may be more congenial: 

gen byte whichpet = pet1 
qui forval i = 2/20 { 
	replace whichpet = whichpet + `i' * pet`i' 
}

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of sara khan
Sent: 05 February 2008 22:03
To: statalist@hsphsun2.harvard.edu
Subject: st: Creating a new variable by combining several

Many thanks Nick. I tried your second suggestion, which did exactly
what I wanted.

Regards

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