DATA Step, Macro, Functions and more

proc copy causes decimal value change?

Reply
Contributor
Posts: 51

proc copy causes decimal value change?

Dear all,

I am facing an unexpected issue here.

There's field X (decimal 7.2) a in a DB/2 database, which contains the value 0.01.

Once I run a proc copy into a SAS dataset (also decimal 7.2), the value is changed to 0.00999...8.

Why does this happen? It does not behave like this for e.g. 100.00.

Thanks,
Thomas
Trusted Advisor
Posts: 2,113

Re: proc copy causes decimal value change?

0.01 and 0.00999... represent the same real number.

SAS does not store decimal numbers exactly (unlike, say, COBOL). It stores all numbers as real numbers. A base-10 decimal number cannot be represented exactly in a base-2 system (integers can be represented exactly).

There are also a couple of standards for the internal structure of a real number. There is possibility that DB/2 and SAS use different standards, which could exacerbate this problem.

To really tease it out you will have to read the "fine print" in both DB/2 and SAS for numeric representation.

Doc Muhlbaier
Duke
Ask a Question
Discussion stats
  • 1 reply
  • 98 views
  • 0 likes
  • 2 in conversation