Here is another example that may help clarify the numeric precision issue. Note that both X and Y appear to be 1 but they are slightly different when viewed in hex.
132 data test;
133 x=1;
134 y=1/10;
135
136 do i=1 to 9;
137 x+1;
138 y + 1/10;
139 end;
140 x=x/10;
141
142 put x hex16.;
143 put y hex16.;
144 run;
3FF0000000000000
3FEFFFFFFFFFFFFF
Whenever the numeric variable is manipulated with an arithmetic function, the manipulation is done in binary. In other words, the floating point number is manipulated in binary and the result we see is the decimal form of the manipulation. SAS does not convert the number to decimal form, and then perform the manipulation in decimal. Therefore, no matter what SAS step you use, PROC SQL, DATA Step or any other procedure, there is a chance that the binary mathematics will not result in the decimal mathematics. The reason that SAS uses floating point representation is because this representation of numerics is what the operating system can easily manipulate. Using floating point allows the operating system to manipulate the bytes SAS stores without the need to convert those bytes to a binary form. This saves a significant amount of processing time. Additionally, using floating point representation, SAS can store numbers with larger magnitude and greater precision with less bytes than if we used a decimal representation.
... View more