Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Formatting variables


From   "Siyam,AA (pgr)" <A.A.Siyam@lse.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Formatting variables
Date   Thu, 13 Jun 2002 18:51:04 +0100

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/



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