| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: a variable is decreased by 1 ? Thanks
Dear Kris, dear Nick,
Thanks for the help. Before posting this request, I did try setting the
variable type to 'long' but that did not resolve the problem. However,
Kris' suggestion is spot on! So, thanks Kris for the immediate solution.
And thanks Nick, for the explanation which I am going to study now to
prevent these kinds of problems in the future.
Gijs
De Swerdt, Kris wrote:
Gijs,
Is it possible that the variable pid is of storage type double and pidold of storage type float?
Maybe you can try:
gen double pidold=pid
Kris
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Gijs Dekkers
Sent: maandag 8 januari 2007 14:06
To: [email protected]
Subject: st: a variable is decreased by 1 ?
Dear fellow Stata-users,
I really would appreciate some help with this strange problem...
I have a panel dataset, with the individual number 'pid' and the year
variabele 'jaar'. The variable pidnew is an alternative
individual-identification number. This variabel, and 'jaar' don't really
do anything, but I include it to show that the individual does not
changes in what follows.
So, the starting dataset is:
. list pid pidnew jaar if (pid==17025101 & jaar==2002)
+--------------------------+
| pid pidnew jaar |
|--------------------------|
10597. | 17025101 62 2002 |
+--------------------------+
So this is the data line of individual 17025101 in the year 2002. Now I
create a copy ('pidold') of this individual identification number,
. gen pidold = pid
. list pid pidold pidnew jaar if (pid==17025101 & jaar==2002)
+-------------------------------------+
| pid pidold pidnew jaar |
|-------------------------------------|
10502. | 17025101 1.70e+07 62 2002 |
+-------------------------------------+
The resulting variable is difficult to read, for it is in the scientific
notation. So I change the format...
. format pid pidold epid %14.0f
. list pid pidold pidnew jaar if (pid==17025101 & jaar==2002)
+-------------------------------------+
| pid pidold pidnew jaar |
|-------------------------------------|
10597. | 17025101 17025100 62 2002 |
+-------------------------------------+
And all of a sudden, the variabele 'pidold', which is supposed to be
equal to 'pid' has decreased by one! Or, which is more likely, the 'gen
pidold = pid' has not done what it should have done, because the format
of pidold was set so that information was lost. However, I cannot set a
format of a variable prior to its existence.
I have also tried juggling with 'recast' and different formats, but
nothing seems to help.
I would really appreciate your help in finding a solution!
Gijs
--
Gijs Dekkers
Attach� Federal Planning Bureau
Research fellow CESO, Katholieke Universiteit Leuven
Kunstlaan 47-49 Avenue des Arts
1000 Brussels, Belgium
phone ++32/(0)2/5077413
fax 7373
skype gdekkers2209
[email protected], [email protected]
**********************************************************************
Disclaimer: This e-mail may contain confidential information
which is intended only for the use of the recipient(s) named above.
If you have received this communication in error, please
notify the sender immediately and delete this e-mail from
your system.
Please note that e-mail messages cannot be considered as official
information from the Federal Planning Bureau.
**********************************************************************
*
* 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/