Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

st: Macro dissapears after forval or foreach

From   <>
To   <>
Subject   st: Macro dissapears after forval or foreach
Date   Wed, 24 Feb 2010 15:28:28 +0100

Dear Statalisters,

I'm just curious why running macros in forval or foreach 
disappear after the loop has finished.


foreach x in 0 1 {	
di "value: `x'"
di "value: `x'"

Following Stata 11 help for foreach and forvalues, 
both commands set local macros to given values.
According to the manual locals are available 
during the execution of the program or do-file 
unless they are deleted or overwritten.
So it should be there, shouldn't it? 

With dynamic value lists or "continue" there is some 
sense in preserving the last processed value.


Yes, I know workarounds... ;-))

Best wishes 


*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index