Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: renaming contents of local macros


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: renaming contents of local macros
Date   Fri, 10 Sep 2004 11:06:28 +0100

To expand on this a little, without giving 
the whole story: 

1. A macro is a named string. So in 

local unlucky "13" 

the macro has name -unlucky-, and contents 
"13". 

2. When you go 

local fitted "`endog'" 

all you are doing is saying "the local with name 
-fitted- should now have the contents of the macro 
with the name -endog-". If -fitted- didn't exist before, 
it is created; if it did, its contents are overwritten. 

3. In your case -fitted- previously contained the
names 

__000003 __000005 __000007

which from context are names of temporary variables. 
Note that nothing you are doing above -rename-s those
temporary variables. They keep whatever names they had 
before. 

Also, note that if you ran this program again the 
names might look different. This is a matter of Stata's 
internal housekeeping. If I go

tempvar lucky 

Stata reserves some name -- it might be __000008 -- and
it established a little rule for itself: if I refer to 
`lucky', this means __000008 (unless and until I overwrite
the contents of -lucky-). 

Nick 
n.j.cox@durham.ac.uk 

Nick Cox
 
> . local fitted "`endog'" 
 
> Patricia Sourdin
>  
> > I have a question on renaming a tempvar in anyone could help please.
> > I would like to replace the contents of the macro tempvar 
> > 'fitted' with the 
> > contents of another macro 'endog'
> > eg replace the just the names in 'fitted' with the names in 'endog'
> > 
> > 
> > di "`fitted'"
> >  __000003 __000005 __000007
> > 
> > di "`endog'"
> > HHinc_no_invest invest_inc hyperindex
 

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