Amani,
Whenever you're dealing with identifiers, you should create variables
as doubles. What's happening to the last couple of digits may just
be rounding error resulting from the fact that floats don't have
enough digits of accuracy for what you're doing.
Cheers,
Mark
Quoting "Siyam,AA (pgr)" <[email protected]>:
> Dear Stata-listers,
>
> I am sorry to bother you with, but I have checked the FAQ
> contents and have spent a few hours now trying to understand
> what STATA is doing with the following:
>
> basically I have an identification variable "snid" that should
> be made-up of 9 digits, arranged as follows
> digit 1 = Oblast no. (1 to 8)
> digits 2-3=rayon no. (01 to 09)
> digits 4-5=population point (01 to 55)
> digits 6-7=segment no. (01 to 18)
> digits 8-9=household number (01 to 20)
>
> Instead for some of the files I have, "snid" coming out with 8
> digits as a result of bad coding ( rayon number above should
> have been stored as 01 to 09 but instead was entered as 1 to
> 9). What I thought I could do was the following
>
> . destring id, gen(snid) float
> . format snid %9.0f
> . gen hhid=100000000 + (snid-10000000)
> . format hhid %9.0f
> . list snid hhid
> snid hhid
> 1. 11010101 101010104
> 2. 11010102 101010104
> 3. 11010103 101010104
> 4. 11010104 101010104
> ...
> 24. 11010401 101010400
> 25. 11010402 101010400
> 26. 11010403 101010400
> 27. 11010404 101010400
> 28. 11010405 101010408
> 29. 11010406 101010408
>
> I can see that "zero" has been added, I can't understand why
> is STATA changing the last two digits of the newly created
> variable "hhid" .
>
> Many thanks for your help in advance.
>
> Amani
> *
> * 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/
>
Prof. Mark Schaffer
Director, CERT
Department of Economics, School of Management
Heriot-Watt University, Edinburgh EH14 4AS
tel +44-131-451-3494 / fax +44-131-451-3008
email: [email protected]
web: http://www.som.hw.ac.uk/ecomes
________________________________________________________________
DISCLAIMER:
This e-mail and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to
whom it is addressed. If you are not the intended recipient
you are prohibited from using any of the information contained
in this e-mail. In such a case, please destroy all copies in
your possession and notify the sender by reply e-mail. Heriot
Watt University does not accept liability or responsibility
for changes made to this e-mail after it was sent, or for
viruses transmitted through this e-mail. Opinions, comments,
conclusions and other information in this e-mail that do not
relate to the official business of Heriot Watt University are
not endorsed by it.
________________________________________________________________
*
* 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/