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!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 427 views
  • 2 likes
  • 2 in conversation