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: Preserve and restore within a foreach loop


From   Sergiy Radyakin <[email protected]>
To   [email protected]
Subject   Re: st: Preserve and restore within a foreach loop
Date   Wed, 22 Dec 2010 10:27:41 -0500

On Wed, Dec 22, 2010 at 5:07 PM, Florian Seliger <[email protected]> wrote:
> 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
1. check that this file^^^^ really contains the variable pat_var

> preserve
>
> foreach file in ... {

2. check that all the files in this list ^^^^^^^^^^^^^^ really contain
the variable pat_var
3. Output the filename in the loop:
display `"`file'"'
to monitor how far the program goes. If the problem is with a
particular file, this will help
identify which one is problematic.


Best, S.R.


>

> 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/
>

*
*   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