[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"NEYMOTIN, FLORENCE" <neymotin@calmail.berkeley.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: question on datatypes |

Date |
Thu, 20 Oct 2005 05:40:42 -0700 |

that is a good idea. thanks for the help!! florence On Thu, 20 Oct 2005 10:25:08 +0100 "Nick Cox" <n.j.cox@durham.ac.uk> wrote:

This is a frequent question on Statalist.

If you what are reading in, although it looks

like a standard numeric variable with a decimal

point, is really some kind of identifier or code, then I think by far the safest strategy is to read it in as a string variable and then do string manipulations on it. This can include removing the point.

Even if you read it in as -float- and then convert

to -long- it is all too likely that errors will

be introduced in the last digit or so.

As a thread yesterday advised, -search precision-

and look at the FAQs there mentioned. The underlying

issue is that computers are really doing calculations

in binary, not decimal. A massive amount of cleverness goes into

hiding this fact from the user, and even the programmer, but it is inescapable and on occasions can bite you.

Nick n.j.cox@durham.ac.uk

NEYMOTIN, FLORENCE

I have variables that are coded in as 2-3 digits and 6 decimal places after that, e.g. 150.089873 and I want to convert this to get rid of the decimal places so it looks like 150089873 but when I just multiply by 1000000 then it keeps storing it as a "float" display i.e. 1.5E8 and more than that, the last decimal places are actually INCORRECT in the new version...it will say 1.50089875 instead...which is INCORRECT. I am using Stata 8 and that is where this problem occurs. I was wondering what the easiest way is to change datatypes that something is input in so that it will not be a problem.

* * 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/

* * 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/

**References**:**st: RE: question on datatypes***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: RE: Question on Removing Superfluous Data** - Next by Date:
**RE: st: Re: a question on function int** - Previous by thread:
**st: RE: question on datatypes** - Next by thread:
**st: RE: RE: Question on Removing Superfluous Data** - Index(es):

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