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, statalist.org is already up and running.


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

st: Preserve and restore within a foreach loop


From   Florian Seliger <florian.seliger@gmx.de>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index