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

st: RE: Formatting variables


From   "Steichen, Thomas" <STEICHT@RJRT.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Formatting variables
Date   Thu, 13 Jun 2002 14:04:50 -0400

-float- only allows for 7 or 8 significant digits.

Kill that option on -destring- and it should work.

Tom



> -----Original Message-----
> From: Siyam,AA (pgr) [mailto:A.A.Siyam@lse.ac.uk] 
> Sent: Thursday, June 13, 2002 1:51 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: st: Formatting variables
> 
> 
> 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/
> 
CONFIDENTIALITY NOTE:  This e-mail message, including any attachment(s), contains information that may be confidential, protected by the attorney-client or other legal privileges, and/or proprietary non-public information.  If you are not an intended recipient of this message or an authorized assistant to an intended recipient, please notify the sender by replying to this message and then delete it from your system.  Use, dissemination, distribution, or reproduction of this message and/or any of its attachments (if any) by unintended recipients is not authorized and may be unlawful.




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