Statalist The Stata Listserver


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

st: new local macro from results of loop


From   Ronnie Babigumira <[email protected]>
To   [email protected]
Subject   st: new local macro from results of loop
Date   Wed, 30 May 2007 16:35:04 +0200

Dear list

I define a local macro lvstk below which contains variables I would like to process further. For example

local lvstk "cattle largeanims calves smallrums smallanims"

foreach v of local lvstk {
	egen `v'nbeg = sum(liv_begnum) if `v', by(houscode qtr)
	egen `v'nend = sum(liv_endnum) if `v', by(houscode qtr)
}

how do I automatically put the new variables being generated into a new macro

say

local lvstknos "cattlenbeg cattlenend ....and-all-the-other-stuff-coming-out-of-the-foreach-loop"

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