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

st: string to number -- limitations

From   baum <>
To   StataList <>
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??
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.

Christopher F Baum, Boston College Economics, Chestnut Hill MA 02467 USA
* For searches and help try:

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