BookmarkSubscribeRSS Feed
gdudley720
Calcite | Level 5

We have an issue where we are adding a supplied number to a starting point number to calculate which observation is selected.  The problem is every once in awhile the incorrect observation is selected.  I.E.  73946.6 + 8212.4 should equal obs # 82159 but 82158 is selected instead.  Is there a way to correct this in SAS?

3 REPLIES 3
Haikuo
Onyx | Level 15

Not sure if I have completely understood your issue. However, the first thing comes to my mind that it might be about precision. Apply round() or ceil() or floor() etc consistently and see if it gets fixed.

Good luck,

Haikuo

jakarman
Barite | Level 11

I have seen this happening more often as result of not understanding what precision (floating point Ieee standard) has as impact.

Calculating and integer from decimal fractions is a bad idea. Just think on the following :

3 * 1/3 =? 1          3 * 0.3 =0.9 ?      3*0,3333 = 0,9999 ? or 1    3*0.333 333 333 333 333 333 =?

The floating point is having about 12 meaningfull digits.

---->-- ja karman --<-----
Ksharp
Super User

It seems that it is a FORMAT problem .

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!

How to Concatenate Values

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.

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
  • 3 replies
  • 858 views
  • 5 likes
  • 4 in conversation