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]

Re: st: RE: RE: Command accepts only global macros


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: RE: RE: Command accepts only global macros
Date   Thu, 31 May 2012 08:38:37 +0100

My reply was that what you report cannot be correct even in principle.
I stand by that point, which is basic Stata logic. Please don't shoot
at the messenger.

More concretely, Joerg Luedicke posted an counter-example showing that
your assertion is not correct. You can run it and test it. Here's
another with -logit-.

sysuse auto
gen hiweight = weight > 3000
local mylist foreign mpg
mvdcmp hiweight: logit `mylist'

As for your example here, is this actual code copied and pasted from
real interaction with Stata and all lines from the same file or the
same interactive session? If so, then I agree: these commands should
produce the same result. So something is wrong, but nothing backs your
original assertion. I still suspect that your real code is wrong in
some other way. If the -local- is defined in the same place, then
there is probably a typo somewhere that you are missing.

Others can naturally join in the discussion. But if this thread does
not resolve the matter to your satisfaction, I advise taking your
question to Stata tech-support, who will, I confidently predict, want
to see your evidence for what you claim, or suspect to be true.

Nick

On Thu, May 31, 2012 at 7:52 AM, Kohvakka Roosa <[email protected]> wrote:
> 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: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
> Sent: 30. toukokuuta 2012 19:28
> To: '[email protected]'
> 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
> [email protected]
>
> 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/

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