I am using the below code, the intent is to verify that the sum/difference of three columns equals another column. I am not getting the intended output.
I also tried the commented line but got the same output:
data rules;
set other_data;
format delta value $20.;
if not missing(d_net_co) then do;
/*if D_NET_CO ne (D_GCO + D_BKCO - D_RECOVERIES) then*/
if D_NET_CO - (D_GCO + D_BKCO - D_RECOVERIES) ne 0 then
edit_67 = 1;end;
if edit_67 = 1;
Value = (D_GCO + D_BKCO - D_RECOVERIES);
Delta = value - d_net_co;
keep rssd_id segment_id d_net_co d_gco d_bkco d_recoveries value delta;
run;
Please find the attachment that shows the output.
Can someone help me understand why the delta column containing zero's are included with the output?
Numerical precision.
Computers can't store decimal numbers/fractions exactly.
Round your answer before comparison for deletion.
ROUND() function
Not sure I understand the issue, why would you not get records in your output with delta values of zero? 🙂
Numerical precision.
Computers can't store decimal numbers/fractions exactly.
Round your answer before comparison for deletion.
ROUND() function
A requirement set by the fed for this field is that it it have 6 decimal places. Will the round function solve the issue rounding that far?
Looks like it did, thanks!!
The second parameter in ROUND function allows specification of precision.
Round(VAR, 0.000001) ;
Actually the SAS Round function has lots of fun possibilities. You can round to practically any multiple. So Round(value,7) or Round(value, 0.0006) are valid and round to the nearest multiple of 7 or 0.0006. I will admit that practical uses for rounding to 1.7 may be few and far between but when needed can save a LOT of possibly obnoxious code.
I've only ever used it to truncate what I needed, never thought of it to force a number longer. I guess it's nothing I've ever come across. Very useful. A nice tool to add to the toolbox.
Thanks!!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.