BookmarkSubscribeRSS Feed
ChrisNZ
Tourmaline | Level 20

I recently got annoyed comparing data that showed no difference even when displaying (supposedly) all possible digits .

 

Using long formats was not enough; I had to derive the difference AND use a long format to finally unhide the difference in value.

 

Consider:

data _null_; 
  X=input('409D593333333333',hex16.);
  Y=input('409D593333333334',hex16.); 
  Z=X-Y;
  putlog X 32.20 / Y 32.20 /@1 Z 32.20; 
run;
       1878.30000000000000000000
       1878.30000000000000000000
         -0.00000000000022737368

Am I mistaken thinking that this behaviour is unintended, and that X and Y should be shown with a different value when using a long format?

I know that the difference is the 17th digit, which is beyond numerical precision. That's not the point. We have a difference at the end of the number, we should see it when displaying the whole number.

 

Y is the badly rounded value by the way, but you wouldn't know it by looking at the 3 lines above. You need further computations.

 

1 REPLY 1
Astounding
PROC Star

Just one piece of the pie here ... the 15-digits of precision limit that is often mentioned is for integers.  Decimal fractions may be imprecise with less than 15 digits.

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
  • 1 reply
  • 269 views
  • 0 likes
  • 2 in conversation