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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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