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: RE: Command accepts only global macros


From   Nick Cox <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Command accepts only global macros
Date   Wed, 30 May 2012 17:28:22 +0100

I don't see any concrete evidence here, just an assertion of a problem. 

In any case this appears to rest on a misunderstanding of how Stata commands work. Suppose you type any command 

anycommand $myglobal `mylocal' 

This is generic: we are imagining a call to a program -anycommand- using one global and one local macro reference. 

What then happens is that part of Stata interprets global and local macro references and replaces them by their contents -- including empty strings if they are not defined -- and then -anycommand- sees the result of that interpretation. 

Thus there is no sense in which commands do or do not accept macros as part of their input, as no command even sees any macro, as such; it sees only the contents of that macro. 

At a wild guess, Kohvakka Roosa is experiencing quite a different issue, namely defining a local macro in one place, and then attempting to refer to it in another. But that ignores what a local macro is -- it is local to whatever program, do-file, do-file editor contents or interactive session in which it is defined, and not visible elsewhere. 

If this is not the case, Kohvakka Roosa should give more details of concrete experiences that somehow give rise to this impression. 

Nick 
n.j.cox@durham.ac.uk 

Kohvakka Roosa

Does anyone have any idea why some commands accept only global, and not local, macros in them? E.g. with  "regress" you can use local macros for the depvar and indep vars, no prob. But with this user-written command "mvdcmp" I am using (a decomposition) I can only define the dependent variable, indep variables and the estimation command using global macros.

I can do this all right, just wondering why this is. 

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