Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: macro problem


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: macro problem
Date   Thu, 22 Jul 2004 18:41:23 +0100

-local- means that. Your do file can't see the locals 
in the main interactive session. 

locals are local to a "program", here interpreted 
broadly to mean 
	0 the main session 
	1 anything defined by a -program- command 
	2 anything in a file run by -do- or -run- 
	3 code in the do file editor 

At least that's my attempt to summarize, itself
subject to correction. 

This is usually a feature: it means your do files 
can have their own macros and that you can -do- 
or -run- them regardless of what locals you have
in the main session. 

So, you can define your macro within the do 
file; or pass it as an argument; or put in 
a global. 

Nick 
[email protected] 

Andrea Molinari
 
> I'm (also!) trying to run a very very simple macro to save me 
> writing lots
> of regressors every time I change the specification, but it 
> does not seem to
> be working when I run it on my do-file.  Ideally, I'd want to 
> define a local
> for each specification, but for now I need to have a core 
> model and then add
> more variables.
> 
> I'm writing:
> local grav lrgdp95m lrgdp95x lrgdp95pcm lrgdp95pcx adj 
> lingtie ldist eumxc
> 
> regress lrebilm `grav'
> 
> (and also tried local grav "lrgdp95m lrgdp95x lrgdp95pcm 
> lrgdp95pcx adj
> lingtie ldist eumxc")
> 
> But the macro is not interpreted when I'm running it from the 
> do file (it
> does work either way when I type it on the Stata Command window).
> 
> I guess I should be missing something in my do file, but 
> can't figure out
> what it may be. Any suggestions are more than welcomed!

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