BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RJ2016
Fluorite | Level 6

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

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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):

 

View solution in original post

2 REPLIES 2
Astounding
PROC Star

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?)

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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):

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 941 views
  • 1 like
  • 3 in conversation