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: RE: Problem with -recode- and temporary variables


From   Sergiy Radyakin <[email protected]>
To   [email protected]
Subject   Re: st: RE: Problem with -recode- and temporary variables
Date   Thu, 11 Nov 2010 17:59:58 -0500

Elan, AFAIK the temporary filenames and temporary variable names are
orthogonal to each other. So even if the tempdir is littered with
older temp files and parallel sessions of Stata are working, that
should not affect the tempvar command.

Alan, IMHO the problem is exactly what Stata says: there is already a
variable named __000000 in the dataset. For example:

. sysuse auto
(1978 Automobile Data)

. gen __000000=1

.
. recode rep78 2=9
__000000 already defined
r(110);

end of do-file

r(110);

.


Check by describing your data immediately before recoding.

How can this happen? I beleive there is more than one way, but the
most straight is that the dataset has been saved in a procedure which
requested some tempvars (perhaps in another session).
Obviously the solution is to:

drop __00*

before saving the dataset (or a variation of the above, depending on
how secure you want to be).
Note also, that if you generate the tempvar above by requesting the
new tempvar name in the same session, the recode statement works
(since it will internally generate the __000001 tempvar and will avoid
the collision).

It is not clear to me why the "variable exists" situation here causes
fatal error??? Why not just pull another candidate name (and repeat
until a suitable candidate is found)?

Hope this helps.

Sergiy Radyakin,
Economist, World Bank









On Thu, Nov 11, 2010 at 2:43 PM, Cohen, Elan <[email protected]> wrote:
> Alan,
>
> Go into your temporary directory (-di c(tmpdir)-) and delete any files starting with "ST".
>
> This problem usually occurs when Stata does not shut down properly.
>
> HTH,
>
> - Elan
>
>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf Of
>> Alan Neustadtl
>> Sent: Thursday, November 11, 2010 14:26
>> To: [email protected]
>> Subject: st: Problem with -recode- and temporary variables
>>
>> I am trying to recode a variable and getting an error that a temporary
>> variable is already defined.  I have rebooted and restarted Stata but
>> still get the same error message.
>>
>> If anyone can shed some light I would appreciate it.  The
>> code I am running is:
>>
>> . recode region (1/4 9=0 "Blue")(4/8=1 "Red"), gen(redblue)
>> __000000 already defined
>> r(110);
>>
>> Sincerely,
>> Alan
>> *
>> *   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/


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