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

Re: st: tostring double wishlist


From   Nicholas Winter <nw53@cornell.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: tostring double wishlist
Date   Tue, 04 Nov 2003 13:39:19 -0500

You want to use the format() option of -tostring-, to tell it not to use the default display format:

. tostring ssuin, gen(ssuidc) format(%012.0f)

for example... (The use of %012.0f, rather than %12.0f, will create any necessary leading zeros.)

--Nick Winter


At 10:01 AM 11/4/2003 -0800, you wrote:

Hi,

I had a bit more trouble than I anticipated converting
a 12-digit double to a string.  The string and number
are below:

     +--------------------------+
     |        ssuid      ssuidn |
     |--------------------------|
  1. | 019003754630   1.900e+10 |
     +--------------------------+

A simple tostring command gives the results below:

. tostring ssuidn, gen(ssuidc) force
ssuidc generated as str11
ssuidc was forced to string; some loss of information

. list ssuidc in 1/1

     +-------------+
     |      ssuidc |
     |-------------|
  1. | 1.90038e+10 |
     +-------------+

expressed in scientific notation rather than like
'019003754630' above.

Thanks

__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
*
*   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/
--------------------------------------------------------
Nicholas Winter t 607.255.8819
Department of Government f 607.255.4530
308 White Hall nw53@cornell.edu
Cornell University falcon.arts.cornell.edu/nw53
Ithaca, NY 14853-4601
*
* 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