Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: Storing macros after Stata session is closed


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: RE: Storing macros after Stata session is closed
Date   Mon, 22 Jan 2007 16:26:41 -0000

To expand on one point: If I put this 

local rachel "Rachel" 

in a do file and run that file, that 
avails me nothing as far as the main 
interactive session is concerned, because 
the definition is, as said, local to that 
file and I can't see it from the main session. 
(As often pointed out, this is a feature on 
which much of Stata depends.) 

There could be several extra comments
on this but on the whole I suspect that the 
main information that Rachel does not appear
to know but might find useful is the scope 
for saving little definitions as characteristics. 

Otherwise it is as it seems: you can (and essentially
must) redefine globals in do files or programs, if 
you do not want to do that interactively. 

But tastes differ. 

No doubt at least some Stata users do this a lot. I almost
never do. I would then have to remember or look 
up the definitions, which I generally prefer not to do. 

Nick 
[email protected] 

Nick Cox
 
> Macro contents are not saved within data files. Therefore 
> you can only store their contents in other ways in Stata 
> data files (notably as characteristics) or you can arrange
> that locals or globals are re-defined in a new session. 
> Thus globals you always need may be defined in profile.do
> or globals you sometimes need in some other .do file that you
> run at your discretion. As locals may be only be defined _locally_ 
> they raise other issues which range from not re-defining them 
> to the more esoteric command -c_local-, of which it has been 
> said that you should only use it once you have worked out what
> it does and why it is dangerous, despite the fact that there is 
> no documentation for it. 

Rachel
  
> > Is there a way to store local or global variables for use in future
> > Stata sessions?  I realize that one can simply store the definitions
> > in a do file, but I'm wondering whether there is a simpler 
> way.  I've
> > looked in the programming manual, but did not find an answer.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index