Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: a question about tempvar


From   Jian Zhang <[email protected]>
To   [email protected]
Subject   st: a question about tempvar
Date   Mon, 6 Feb 2006 15:40:27 -0800 (PST)

Dear Stata Users,

Have you run into the following problem when using command tempvar?  I can
not fix the problem.  Hope that you can help me out.

The problem is as follows. Sometimes I need to use some temporary
variables.  So I use command tempvar.

For example, my do file is the following:

use file.dta, clear

sort eid
tempvar temxxx
by eid: gen `temxxx'=_n
drop if `temxxx'!=1

sort eid

save file1.dta, replace

The problem is that after I run the whole do file, which will save the
data in file1.dta, next time I open file1.dta, I ALWAYS find that there is
an additional variable, which is __000000, is added to my data.  All of
the values of this variable is 1.  So I have to delete this variable and
resave the whole data.    I have run into this problem several times and
could not find why and how to fix it.  If this is going to be the way, it
seems to me that it is much more convinent that I could just creat a new
variable called temxxx and then drop it later on when I don't need it anymore.

Is there a way that I can get around this? Thanks.

Jian Zhang


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index