Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Deleting macros within a loop


From   Rebecca Pope <[email protected]>
To   [email protected]
Subject   Re: st: Deleting macros within a loop
Date   Sat, 6 Jul 2013 12:23:38 -0500

Gareth,
Which "usual commands" are you having problems with and what do you
mean by "don't seem to be working"? You are asked to specify these
things.

Just guessing at what you are trying: -macro drop- works fine for me
(see silly example below, run with Stata 12). You obviously wouldn't
want to use _macro drop _all- if you have a macro in your -while-
statement.

local i = 1
while `i' < 5 {
   local j = `i' - 1
   di "The value of j is `j' and the value of i is `i'"
   macro drop j
   local ++i
}

Regards,
Rebecca

On Sat, Jul 6, 2013 at 11:08 AM, G. Anderson <[email protected]> wrote:
> Hi,
>
> I have written a programme in stata which has a while loop in it. Within the
> loop I create local macros.
>
>
> Ideally of the loop before I move on to the next iteration I would like to
> clear the memory of all macros created. Usual commands don't seem to be
> working when I am in the loop. Is there a way I can delete macros whilst in
> a loop?
>
> Thanks,
>
> Gareth *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index