Statalist The Stata Listserver


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

Re: st: How to make macro variables lastan entire session?


From   <rhanig2@uiuc.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: How to make macro variables lastan entire session?
Date   Tue, 29 Aug 2006 22:25:33 -0500 (CDT)

Thanks! For some reason, when I put quotation marks around $base I get the error message 

"var1 var2 var3 var4 invalid name
r(198);

But when I put nothing around $base, everything works fine. And this holds if I use multiple global macros. For example, the following works:

tabstat $base $ace $case, by(person) stats(n mean median cv)

Thanks again!
Ross


------------------------------

Date: Mon, 28 Aug 2006 19:44:15 +0200
From: Philipp Rehm <Philipp.Rehm@gmx.de>
Subject: Re: st: How to make macro variables last an entire session?

- -global- may be what you are looking for. See "help global"

global base "lncgdp s n popuned popprimed popseced pophighed openc"

regress "$base"

HTH,
Ph


rhanig2@uiuc.edu wrote:
> Hi,
>
> I was wondering if anyone knows how to define or save macro variables so they last for an entire stata session and not just while the do-file is running. I've been defining macro variables  as is below with the local command where the command `base' substitutes for all the variables in quotes below for example. But if I run the local command, and then later highlight some line of code with `base' and "do" it, then Stata no longer associates `base' with the set of variables. Anyone know any ways around this problem? I've tried saving using global macros and that doesn't seem to help.
>
> local base "lncgdp s n popuned popprimed popseced pophighed openc"
>
> regress `base'
>
> Thanks,
> Ross
>
>
*
*   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/



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