08-04-2015 02:40 PM
If I run the below data step I see SAS behaving in strange manner. Variable y resolves to 1.2. SAS thinks x(1.2) is less than y. Any help will be appreciated.
if x<y then Confused="Yes";
08-04-2015 03:12 PM
SAS numbers are represented internally by floating point values. 1.2 doesn't have an exact representation as a floating point number, so its internal value is an approximation. That approximation will take different values depending on how it was arrived at. Add the following statements and see what happens
if round(x, 0.1) < round(y, 0.1) then RoundConfused="Yes";
08-04-2015 04:50 PM
Use the HEX16. format to look at how these two different numbers end up getting stored into the 8 byte IEEE floating point format.
put (x y) (= hex16. /) ;
put / (x y) (= hex16. /) ;
08-04-2015 11:29 PM
Much reading available on this topic.