Length of Numeric Variables
The following two sets of code are instructive. Both simply add the number 1/10 ten times.
The sum should be one.
Data Tenth;
|
Data Tenth;
|
In the first-3 byte disk storage-case the output is:
OBS X DECIMAL HEX
1 0.09999 0.0999908447 3FB9990000000000
2 0.09999 0.0999908447 3FB9990000000000
3 0.09999 0.0999908447 3FB9990000000000
...
8 0.09999 0.0999908447 3FB9990000000000
9 0.09999 0.0999908447 3FB9990000000000
10 0.09999 0.0999908447 3FB9990000000000
======= ============ ================
0.99991 0.9999084473 3FEFFF4000000000
In the second-8 byte disk storage-case the output is:
OBS X DECIMAL HEX
1 0.1 0.1000000000 3FB999999999999A
2 0.1 0.1000000000 3FB999999999999A
3 0.1 0.1000000000 3FB999999999999A
...
8 0.1 0.1000000000 3FB999999999999A
9 0.1 0.1000000000 3FB999999999999A
10 0.1 0.1000000000 3FB999999999999A
=== ============ ================
1.0 1.0000000000 3FEFFFFFFFFFFFFF
The only difference is that in the first case "1/10" is stored on disk in 3 bytes of disk space and in the second case "1/10" is stored in 8 bytes.
You would think that SAS could store a tenth properly. In the data step the results are identical. Why are there different results in the Proc step?