Hi @1239,
If those numbers (in your real data) are the results of calculations rather than hardcoded literals, checking exact equality ("if a= ...") is likely to fail. As Tom has pointed out, you would most probably miss relevant digits.
Example:
1200 data _null_;
1201 a=exp(4.25769*exp(2.082));
1202 put a best12. / a best32.-L / a 18.1-L / a hex16.;
1203 if a ne 677056981379146 then put 'unequal';
1204 if a=677056981379145.9 then put 'OK 1a';
1205 if a=6.770569813791458E14 then put 'OK 1b';
1206 if put(a,hex16.)='43033E3CE6F1424F' then put 'OK 2';
1207 if round(a,1e7)=6.7705698e14 then put 'OK 3';
1208 if put(a,best12.)='6.7705698E14' then put 'OK 4';
1209 run;
6.7705698E14
677056981379146
677056981379146.0
43033E3CE6F1424F
unequal
OK 1a
OK 1b
OK 2
OK 3
OK 4
So, there exist numeric literals for which exact equality holds (677056981379145.9 and 6.770569813791458E14), but none of the common numeric formats (w.d, BESTw., Ew., etc.) will show you sufficiently many digits so that you could type them.* Only special formats such as HEX16., BINARY64. or RB8. reveal the full binary content of a numeric variable, which is amenable to exact equality checks. Otherwise you need to resort to tests of only approximate equality, either using numeric or character values (see the last two IF conditions above).
Knowing your data, you could abbreviate those approximate comparisons based on how close other values get to your target value. Each of the three IF or WHERE conditions below works for your sample data:
put(a,best7.)='6.77E14'
round(a,1e12)=6.77e14
abs(a-6.7e14)<1e13
(In theory, the COMPFUZZ function should work as well.)
* Edit: With the non-default setting options decimalconv=stdieee the 18.1 format does show 677056981379145.9.
... View more