Statalist


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

Re: st: local macro trouble


From   "Eva Poen" <eva.poen@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: local macro trouble
Date   Tue, 23 Sep 2008 10:43:51 +0100

Ashim,

a local macro is local to its environment (do-file or program). Thus,
if you define it in a do-file, it will cease to exist (i.e. be empty)
after the do-file has finished. Just as local macros, when defined
interactively, don't survive the end of a Stata session.

Btw, if you want to save the sum of a variable in a macro, you don't
need to create a new variable for it.

qui sum twodayfallindex, meanonly
local dispdate = r(sum)

Of course you'd still have to rethink what to do in terms of when you
define your macros.

Eva

2008/9/23 Ashim Kapoor <ashimkapoor@gmail.com>:
> Hi everyone,
>
> Maybe I am getting tired so I am not able to see this. Maybe some one
> else can see it.
>
> I do this : -- >
>
> egen twodayfallindex=sum(twoindex)
> local dispdate = twodayfallindex[_N]
>
>
> in a do file.
>
> and after  I run the do file if I say -macro dir- it does not show up
> in the macros!!
>
> How can that be ?
>
> I don't know why I am unable to initialize this macro : ( !
>
> Thank you,
> Ashim.
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index