BookmarkSubscribeRSS Feed
redfishJAX
Calcite | Level 5
I have an issue and have tried various ways of using the ROUND() function, but it's still not giving me what I need.

Here is the example:

bal lagbal lagbal2
1119.16 -847.64 271.52

The line in the program for the data above is:

if bal=((lagbal*-1)+lagbal2) then paid=0

if I change it to:
if bal ne ((lagbal*-1)+lagbal2) then paid=0
then it works

When I compare the value of the bal and the expression (lagbal*-1)+lagbal2 then I get an exponential number. I have tried to round the variables, and it works for some but not all. Any ideas on what I can do?
2 REPLIES 2
Florent
Quartz | Level 8
Hi,

I faced the same kind of issue and fixed it by forcing SAS to make the automatic conversion to a numeric variable.

In your example, it becomes:

if bal= put(((lagbal*-1)+lagbal2), best32.) then paid=0;


I don't know what really is the problem with SAS (we are still using the version 😎 for such a situation and even don't know whether there is a fix to apply in order not having to implement such crappy solutions...

Kind regards,
Florent
Doc_Duke
Rhodochrosite | Level 12
I'm not sure what you are trying to do, but I suspect that the problem is in

lagbal*-1

Because you didn't use parentheses, SAS has to make a guess about whether the minus sign is subtraction or an infix operator. The multiplication can cause roundoff error (remember that the arithmetic is done in base-2) that makes the equal sign fail.

Does it work if you re-write as

IF bal=(labgal2 - lagbal) THEN paid=0; ?

Subtraction induces less roundoff error than multiplication.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 614 views
  • 0 likes
  • 3 in conversation