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: ocal macros & do file
From
Andrew Dyck <[email protected]>
To
[email protected]
Subject
st: Re: ocal macros & do file
Date
Tue, 26 Apr 2011 16:13:49 -0700
I think I might know what you are experiencing. This is something that
I've encountered when attempting to debug. For example, you have some
code written in Stata's do-file editor and want to test a block of it
so you type into the terminal:
local hello = "Hello"
then you copy and paste your block of code from the do-file editor
into the terminal. An example of this code might be:
local planets = "Earth Mars"
foreach planet of local planets {
di "`hello' `planet'"
}
Which then prints:
Hello Earth
Hello Mars
Then you try selecting the block of code in the do-file editor and hit
CTRL+D to "do" the selected code, which produces:
Earth
Mars
Skipping the local as you mention.
This happens because when you hit CTRL+D, the code is passed as a
temporary do-file (something like STD00000000.tmp) and the local you
defined in the terminal is separate from this file. Using a global for
hello would fix this, or you could re-examine your method of
debugging.
Cheers,
Andrew
>
> 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/
*
* 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/