03-15-2017 10:06 PM
diff = t1 - t2;
t1 t2 diff
12 6 6
14191.65 14191.65 1.818989E-12
The issue is whenever I encounter a large number the difference is reflected as scientific notation where as it should be a 0
low - high = '000000000009';
The number displays as a 0 however when I apply a test such as
if diff = 0 then delete; The test fails and the row still appears
03-15-2017 10:17 PM
Welcome to computing
This is a known 'issue'. Please see the full explanation below.
You can resolve this by formatting your data, using something like 8.1 should be enough.
And you can change your test to:
if round(value, 0.0001) = 0 then <action>;
03-15-2017 10:20 PM
Just responded to a similar question in a different thread. The topic you want to Google is numeric precision. It's not just with SAS, but any computer.
The numbers are likely to be off somewhere off to the right decimal place. The solution is to round the numbers to the number of decimal points that are practically significant to whatever you're doing.
Art, CEO, AnalystFinder.com
03-16-2017 03:22 AM
As the others have already noted, this is an artifact resulting from the way SAS stores numeric values.
Adapt your data step (and other steps that do similar calculations):
data test; set test2; diff = round(t1 - t2,.00001); run;
And you'll get rid of problems caused by precision overflows or numbers that are periodic in binary representation.
03-16-2017 10:41 AM
BTW your example data is wrong because you let a very likely default format of best8. display the values of t1 and t2.
I know this because when I copy your pasted example data and use that in a data step the result is 0.
data example; x=14191.65; y=14191.65; result = y-x; put result= best32.; run;
03-16-2017 02:17 PM
In addition to what others have said, you should avoid testing floating-point values for equality. Instead, test whether the value is within a small amount of the target value:
if fabs(diff) < 1e-6 then delete;