Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Decimals

    Hi all,

    I have one question about decimals. For example, variable age and casi_total in the data set has one decimal. But after I export them to the excel .csv file, it will show something strange. For example, age 88.9 will change to 88.900002, casi_total will change to 22.200001. I want 88.9 and 22.2 in my excel .csv. How can I fix this issue?

    Best,
    Jack Liang

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int patientid float(age casi_total)
     23 88.9 22.2
     49 74.8 94.4
    249 82.9 64.3
    285 78.8   91
    349   77 87.3
    442 69.8   94
    482 75.1 38.5
    539 81.2 53.2
    643 74.9   24
    668 76.6 47.1
    end

  • #2
    Often asked here. The keyword for searches here and in Stata is precision. In essence, Stata on your computer uses binary arithmetic to approximate decimal numbers. Of numbers ending

    .0
    .1
    .2
    .3
    .4
    .5
    .6
    .7
    .8
    .9

    only those numbers ending in 0.0 or 0.5 have exact binary equivalents.

    It's not a problem. There is no fix (that won't make the non-problem worse).

    Comment

    Working...
    X