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

st: string to number -- limitations


From   baum <[email protected]>
To   StataList <[email protected]>
Subject   st: string to number -- limitations
Date   Sat, 12 Oct 2002 14:24:38 -0400

Hi there,
I have converted a 15 digit string into a numerical number by using real()
command. My problem is that now the data is read as floats while I want it
to be in doubles as the string happens to be the caseId of my data. How
do I proceed??
Thanks
Kompal
Very bad idea. There is no way of representing this many digits reliably as a floating point number, even using double precision; the last digit is likely to be random. Keep the case ID as string. If you need to have a numeric variable underlying it (e.g. in order to tsset), use encode. But do not try to generate a 15 digit integer -- it won't work reliably.

Kit
________________________________________________________________________
Christopher F Baum, Boston College Economics, Chestnut Hill MA 02467 USA
[email protected] http://fmwww.bc.edu/ec-v/baum.fac.html
*
* 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