Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: How to consecutively add elements to a macro
From
Thomas Speidel <[email protected]>
To
<[email protected]>
Subject
st: How to consecutively add elements to a macro
Date
Wed, 02 Mar 2011 14:39:36 -0700
***********EXAMPLE**************
local readyvar
use data1.dta
<do something>
save temp1
local readyvar birthday
use data2.dta
<do something>
save temp2
local readyvar <want to _add_ gender to the macro>
use data3.dta
<do something>
save temp3
local readyvar <want to _add_ smoking to the macro>
<...>
use temp1
merge id using temp2 temp3, sort
keep readyvar
**********END EXAMPLE************
My question is how to I add elements to an existing macro without
having to re-type the whole content of the macro each time? Also, if I
understand correctly, local macros exist only if I run the whole do file
at once. In other words, if I run 'chunks' of the do files one at a
time, I would not be able to use the macro that was created in the
previous 'chunk'. Is this one of those cases where a global macro is
preferrable?
Thank you.
--
Thomas Speidel
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/