turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- proc copy causes decimal value change?

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-06-2009 05:16 AM

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

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to ThomasH

05-06-2009 08:18 AM

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

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