Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: RE: Command accepts only global macros

From   Kohvakka Roosa <>
To   "" <>
Subject   st: RE: RE: Command accepts only global macros
Date   Thu, 31 May 2012 09:52:44 +0300

Thank you for the response :)

I fully accept your assumption that I lack understanding, that is somewhat probable.

However, I do know what local macro means (compared to global), and what the command sees (the idea of macros). This is why I posted this message. I was puzzled.


.local macro x1 x2 x3

.mvdcmp groupvar: logit depvar `macro'


.global macro x1 x2 x3

.mvdcmp groupvar: logit depvar $macro


Again, chances are that there is something very obvious I don't understand or see, or something I did wrong. But there were no Statalist entry requirements in terms of intelligence I far as I remember... :)

Peace out,


-----Original Message-----
From: [] On Behalf Of Nick Cox
Sent: 30. toukokuuta 2012 19:28
To: ''
Subject: st: RE: Command accepts only global macros

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. 


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:

*   For searches and help try:

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