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
Florian Seliger <[email protected]>
To
[email protected]
Subject
Re: st: Preserve and restore within a foreach loop
Date
Thu, 23 Dec 2010 10:00:48 -0700
Dear Sergiy,
thank you again. There was another reason why STATA was interrupting running the do-file, but it seems to work pretty fine now.
I was not sure whether this combination with restore works at all with a loop, hence my question.
But I will keep your suggestions in mind for the remaining datasets.
Best,
Florian
Am 22.12.2010 um 08:27 schrieb Sergiy Radyakin:
> 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/
*
* 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/