Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[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 <benjaminvillena@hotmail.com>
To   Statalist <statalist@hsphsun2.harvard.edu>
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index