Statalist The Stata Listserver


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

Re: st: RE: Saving global variables for future Stata sessions


From   Nick Winter <[email protected]>
To   [email protected]
Subject   Re: st: RE: Saving global variables for future Stata sessions
Date   Wed, 14 Feb 2007 14:32:09 -0500

What I would do is this:

Have your .do file (globals.do, say) that has all your global definitions. Then, in each session, don't update them by typing in new global statements to Stata. Rather, add the definition to the global.do file, then re-run it.

If you have global.do in the Stata do editor, re-running is easy. There are various solutions out there for similarly convenient integration of other text editors...

-NW

Rachel wrote:

Nick and David,

Thank you for pointing me to the profile.do file.  The only issue is
that I add definitions from session to session, so I need to
continually update this file.

One way to copy the macro definitions from the command log file and
paste them into the profile.do file each time.

Is there some elegant way to keep  the macro definition commands in a
separate log file?  If Stata can't do this, is there a text editor you
know of that can automatically delete lines that don't begin with
"global" (or local, etc.)?

Thanks very much,
Rachel


On 2/14/07, Nick Cox <[email protected]> wrote:
Communication is easier if you follow Stata's
terminology. By "global variable" I guess you
mean "global macro".

If you want to save global macro contents with
datasets I believe that you must do it indirectly.

You mention .do files. A variant on that is to
add global definitions to your profile.do file,
or to have a file

-------------------------- myglobal.do
global foobar "foobar"
global buzz "fuzz"
global answer = 42
-------------------------

and then to have within -profile.do-
a command

do myglobal

Alternatively, save a global as a characteristic (good),
or in a variable (poor style, but may be practical).

Nick
[email protected]

Rachel

> Is there any program or built-in command that can do this. I'm looking
> for some way other than simply saving the macro declarations as a do
> file and running them each time I open a new session.

*
*   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/

*
*   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/
--
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  [email protected] e
University of Virginia          faculty.virginia.edu/nwinter w
PO Box 400787, 100 Cabell Hall
Charlottesville, VA 22904

*
*   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