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


From   Kohvakka Roosa <roosa.kohvakka@thl.fi>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
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.

E.g. 

.local macro x1 x2 x3

.mvdcmp groupvar: logit depvar `macro'

DOES NOT WORK, BUT

.global macro x1 x2 x3

.mvdcmp groupvar: logit depvar $macro

DOES WORK.


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,

-Roosa




-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: 30. toukokuuta 2012 19:28
To: 'statalist@hsphsun2.harvard.edu'
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. 

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/

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