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: how to display value of local?


From   daniel klein <klein.daniel.81@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: how to display value of local?
Date   Mon, 7 May 2012 23:52:24 +0200

Quian,

if this were a program in Stata's sense it would have worked since the
two lines of code (which better describes what you have here) would
have been executed within that program.

My guess is you defined the -local- in one place (e.g. do-file) and
tried to -display- its contents in another (e.g. interactive session).
As the name "local" suggests, this does not work. The reason is
explained in [P] macro, which you can access typing

. h local

and follow the link.

Here is the relevant part:

"Macros come in two types, global and local. [...] Global macros, once
defined, are available anywhere in Stata. Local macros exist solely
within the program or do-file in which they are defined. If that
program or do-file calls another program or do-file, the local macros
previously defined temporarily cease to exist, and their existence is
reestablished when the calling program regains control. When a program
or do-file ends, its local macros are permanently deleted." (p. 192)

Best
Daniel

-- 
Hi, statalist
    I wrote the following brief program for stata,

    local SigmaMax = 131.05
    display `SigmaMax'

   Unfortunately, I couldn't find that the stata display the value of
SigmaMax, so what's wrong with my program?
*
*   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