BookmarkSubscribeRSS Feed
Kurt_Bremser
Super User

Just to put this thing to rest:

data have;
input score;
format score 5.2;
datalines;
0.2
0.31
0.4
0.6
0.75
0.8
0.9
;

proc freq data=have;
tables score;
run;

data want;
set have;
if score = 0.2;
run;

Final part of the log:

 86         data want;
 87         set have;
 88         if score = 0.2;
 89         run;
 
 NOTE: There were 7 observations read from the data set WORK.HAVE.
 NOTE: The data set WORK.WANT has 1 observations and 1 variables.

So, if the value is 0.2, then the subsetting IF will work, period. If it doesn't work, then you have a different value, but don't see it because of the format.

How are the values created?

 

And please do post the log from this:

data toto;
set toto;
if score=0.2 then output;
run;
FreelanceReinh
Jade | Level 19

Fun fact: Using Windows SAS 9.4M5 with the default setting of system option DECIMALCONV, i.e.,

options decimalconv=COMPATIBLE;

there are seventeen distinct numeric values which are not equal to 0.2, yet indistinguishable from 0.2 when viewed in the common numeric formats w.d, BESTw. and Ew. (with all possible values of w and d). Similarly, 0.31 has eight such "doubles" among the internal numeric representations.

 

The log of the code below shows where the corresponding ranges start and end.

data _null_;
input score hex16.;
put score hex16. +2 (5*score) (best16.-l best32.-l +1 16.15 +1 32.30 e32.);
cards;
3FC9999999999997
3FC9999999999998
3FC99999999999A9
3FC99999999999AA
3FD3D70A3D70A3D6
3FD3D70A3D70A3D7
3FD3D70A3D70A3DF
3FD3D70A3D70A3E0
;

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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
  • 16 replies
  • 2402 views
  • 3 likes
  • 5 in conversation