BookmarkSubscribeRSS Feed
jihunx
Calcite | Level 5

I want to find 'aa2=0.7' row in below code. But it doesn't work. other number is work like 0.6, 0.8, 0.9.

Is it a bug of sas or anything else?

 

 

data test1;

input aa bb cc;
cards;
6 392 2935
7 132 324
8 393 230424
9 3924 2348729
10 456 234235
;
run;
 
proc sql;
create table test2 as
select aa/10-0.1 as aa2, bb, cc
from test1
;
quit;
 
proc sql;
create table test3 as
select *
from test2
where aa2=0.7
;

quit;​

2 REPLIES 2
Kurt_Bremser
Super User

Most decimal fractions can not be represented by a finite binary number, so you end up with imprecisions when doing calculations. Use the round() function to get rid of aberrations (or at least get identical aberrations).

 

For in-depth information, do a google search for "sas numeric precision".

jihunx
Calcite | Level 5
Thank you so much!