I am using SAS 9.4. The following code demonstates an error of the round (x, b) function: Data work.tst; uiva=-0.07918; dciva=0.20066; changeLines=( round(DCIVA,0.02) - round(UIVA,0.02))*10; changeLines2=( round(DCIVA*50) - round(UIVA*50))/5; changeLetters=changeLines*5; if changelines=2.8 then a='Y'; else a='n'; if changelines2=2.8 then a2='Y'; else a2='n'; diff1=changelines - 2.8; diff2=changelines2 - 2.8; output; run; proc print data=Work.tst; run;
Obs
uiva
dciva
changeLines
changeLines2
changeLetters
a
a2
diff1
diff2
1
-0.07918
0.20066
2.8
2.8
14
n
Y
4.4409E-16
0
So rounding by round(x, 0.02) leads to different result than round(x*50)/50. The difference between both is a small delta=4.44e-16 !!! This is a bad mistake, as typically it is often not seen when fomatted values are shown. But it is effective when you make comparsions (see n for comparison a)
Is this bug going to be fixed somehow?
... View more