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: ocal macros & do file
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: ocal macros & do file
Date
Tue, 26 Apr 2011 23:10:36 +0100
Sorry, but I find it difficult to believe that what you report is
exactly right. It is contrary to the logic of Stata.
What I can believe is that a local macro defined in a do-file is not
visible outside it.
That is precisely what -local- means. Local macros are not visible
outside the locale in which they are defined, meaning precisely one of
1. a -program- so defined
2. a do file
3. do-file editor contents
4. interactive session.
You need to use a global macro if you want a macro to make sense
outside the do-file in which it is defined.
Nick
On Tue, Apr 26, 2011 at 9:33 PM, Anjanette Chan Tack <[email protected]> wrote:
> I made a local macro in stata called `access', then a made a do file with a host of commands that use `access'. When I run the do file, it executes some commands without a problem, but it fails to execute others.
>
> To test the whether the commands that fail are typed properly in the do file, I copy-and-pasted them into the stata command window. When I press enter, the commands work perfectly. Have any of you come across something like this?
>
> I can't figure out what the problem is. Obviously, I want to be able to run the do-files and not have to enter these commands on at a time. Additional info: I am using stata 9. Also, all the commands that work are of the form:
>
> tab x, summ(`access')
>
> Whereas the ones that fail are all of the form:
>
> tab x y, summ(`access') means
>
> One would think such commands too simple to cause confusion, but there it is. Thanks a lot in advance for your help!
*
* 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/