02-21-2018 03:10 PM
I'm not getting this:
I created a data set via a do-loop, data x, below.
When I use a w.d format on the value that I 'see' in the output data(value), the value is rounded up(fvalue).
When I create a hard value for 0.245 and use the same w.d format, the value is rounded down(fvalue2).
Clearly, SAS does not see the raw value of 0.245 coming from the data as 0.245.
Question is why?
Thanks for considering and I hope this is clear.
do i= .01 to .99 by .0001;
value = i;
format fvalue fvalue2 8.2;
when is 0.245 not 0.245?
Obs value fvalue rawvalue fvalue2
1 0.245 0.24 0.245 0.25
02-21-2018 07:21 PM
It's actually worse than you think.
data x; do X= .244 to .245 by .0001; Y=round(X,0.0001); output; end; format X Y 20.16; run;
to obtain (on a PC):
Read about numeric precision to know more.