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]

st: Preserve and restore within a foreach loop


From   Florian Seliger <[email protected]>
To   [email protected]
Subject   st: Preserve and restore within a foreach loop
Date   Wed, 22 Dec 2010 15:07:53 -0700

Dear Statalist,

I want to restore a big dataset at the end of each iteration in order to save time ( I don't want to reload the 2,5GB file after each iteration), e.g.

use big_dataset.dta, clear
preserve

foreach file in ... {

joinby pat_var using "`file'"

drop pat_var

...

save changed_"`file'", replace
restore, preserve
}

******

The last command is intended to restore the big_dataset that should be matched with each file specified in the loop. Unfortunately, STATA interrupts the process and tells me that it does not find the variable pat_var.
Hence, the command might not work as intended, but I don't know where I have made a mistake.
Do you have any suggestions?


Thank you,
Florian



*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index