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


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

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index