## Logic failing to pass certification even though values are the same

Solved
Occasional Contributor
Posts: 10

# Logic failing to pass certification even though values are the same

Hi,

I currently have  the below code

if Balance = F_Balance
then Balance_check = 1; else
if Balance = round(F_Balance + Balance_Difference,0.02)
then Balance_check = 1; else
Balance_check = not_OK;

I am currently checking over 500 fields, all pass apart from 1 row which shows

Balance                   =  897.61

F_balance               =  897.02

Balance_Difference =  0.59

now this should pass however it keeps failing check as it should populate Balance_check with a value of 1 however its blank

"1"       repesents pass

"blank" repesents fail

I have even tried removing the rounding 0.02 and still fails this one row, my dataset looks correct but i dont know where i am going wrong, also all fields are numeric formatting

Accepted Solutions
Solution
‎01-10-2017 04:39 AM
Super User
Posts: 9,599

## Re: Logic failing to pass certification even though values are the same

I would say there is a problem with your numeric data (maybe not rounded?).  This is a good examplpe of where posting test data to show what you have would be a good idea.  As from what you have posted:

```data test;
balance=897.61;
f_balance=897.02;
balance_difference=0.59;
balance_check=ifn(balance=f_balance or balance=round(f_balance+balance_difference,0.02),1,.);
run;```

Works fine for me.  Note I simplified your if/else logic somewhat.  Maybe try rounding balance (in fact round each of the values involved):

All Replies
Super User
Posts: 6,754

## Re: Logic failing to pass certification even though values are the same

[ Edited ]

Why would you round to the nearest 2 cents, and expect there to be a match?  You could try changing 0.02 to 0.01 and round to the nearest penny.

Secondarily, do you really have a variable named "NOT_OK"?  (If not, just what are you trying to insert into the numeric variable BALANCE_CHECK?)

Solution
‎01-10-2017 04:39 AM
Super User
Posts: 9,599

## Re: Logic failing to pass certification even though values are the same

I would say there is a problem with your numeric data (maybe not rounded?).  This is a good examplpe of where posting test data to show what you have would be a good idea.  As from what you have posted:

```data test;
balance=897.61;
f_balance=897.02;
balance_difference=0.59;
balance_check=ifn(balance=f_balance or balance=round(f_balance+balance_difference,0.02),1,.);
run;```

Works fine for me.  Note I simplified your if/else logic somewhat.  Maybe try rounding balance (in fact round each of the values involved):

☑ This topic is solved.