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: Temporary variables saved by accident


From   William Buchanan <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Temporary variables saved by accident
Date   Wed, 9 Jan 2013 05:37:09 -0800

Because you told Stata to save the active dataset in memory? The tempvars will be cleared from memory at the end of the session on their own, but if you create them and then save them how would Stata know if they should or shouldn't be saved with the rest of the dataset?  You could also drop the tempvars before saving the dataset to avoid all of this. 

HTH,
Billy

Sent from my iPhone

On Jan 9, 2013, at 5:18, Adrian Sayers <[email protected]> wrote:

> Hi All,
> 
> I have come across some strange behaviour. After saving a file which uses temporary variables, the temporary variables are also saved, and converted to permanent variables. I had assumed this would not happen?
> 
> If i run all the code together i have no problems.
> But if i run part 1 , then part 2 i get an error message of "__000002 already defined"
> 
> I am running version 21.1
> 
> // Part 1
> clear
>    set obs 100
>        gen age_1 = 10
> 
> tempvar P n
>    gen `P' = uniform()
>        sort `P'
>            gen `n' = _n
> 
> save error_test.dta , replace
> 
> 
> // Part 2
>    use  error_test.dta  , clear
> de
>    hist age
> 
> so the work around is
> 
> drop __00*
> 
> But why does this happen?
> 
> Many thanks
> 
> Adrian
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index