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" <[email protected]>
To   <[email protected]>
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: [email protected]
[mailto:[email protected]] On Behalf Of sara khan
Sent: 05 February 2008 22:03
To: [email protected]
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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index