Bookmark and Share

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: is it possible to use local macros to define global macros?


From   Benjamin Villena Roldan <[email protected]>
To   Statalist <[email protected]>
Subject   st: is it possible to use local macros to define global macros?
Date   Sun, 27 Jun 2010 00:39:10 -0400

Hi Statalist,
I'm trying to use several lists of variable names that I want to use in various do files, so in my master do file I define
 
global covar1 x1 x2 x3
global covar2 x4 x5 x6
...
global covar10 x28 x29 x30
 
Then, I want to run regressions in a forvalue loop to use the defined global macros
 
forv a=1/10{
     reg y $covar`a'
}
 
But this approach does not work because the dereferencing operator $ does not include the local macro "a" into the global name.
 
Is there any way I can do this without having to redefine my global macros as local macros in all my do files?
 
Thanks
 
Benjamin


  		 	   		  
_________________________________________________________________


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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index