Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: behaviour of locals


From   Sunil Kumar <stuff.sunil@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: behaviour of locals
Date   Wed, 24 Aug 2011 11:14:39 +0100

Dear Statalisters,

I'm running Stata 12.0 (update level 8th Aug 2011) on a Mac (10.6.8).
My issue is that if I define a local as part of a do file, it exists
only for that particular execution of the do file, but if I type it
into the command window, it exists till I exit Stata, which is what I
understand to be the expected behaviour.

For example:

 sysuse auto, clear

. local test "price"
. reg `test' mpg

works fine if I type commands into the command window or run a do file
that contains both these lines. But if I run the two commands (local
then reg) separately from a do file, one by one, then the regression
only includes a constant, i.e. the local is missing.

Similarly, if I run the local command from a do file and type anything
involving the local into the command line, then the local is still
missing (blank). Am I misunderstanding how locals should behave? I've
tried the same thing on Stata 11 and the local exists till I exit
Stata, irrespective of whether it was defined in a do file or typed
manually.

Thanks.

Sunil
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index