Statalist The Stata Listserver


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

st: a variable is decreased by 1 ?


From   Gijs Dekkers <[email protected]>
To   [email protected]
Subject   st: a variable is decreased by 1 ?
Date   Mon, 08 Jan 2007 14:05:44 +0100

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/




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