BookmarkSubscribeRSS Feed
deleted_user
Not applicable
YRDIF seems to be returning inexact results for me.

If I run the following in a data step:
test1 = yrdif('07JAN2000'd,'07JAN2001'd,"ACT/ACT");
test2 = yrdif('06JAN2000'd,'07JAN2001'd,"ACT/ACT");
test3 = yrdif('08JAN2000'd,'07JAN2001'd,"ACT/ACT");
test4 = 365/365;
and then do a Proc Freq on the results, I get:
Test1=1.0000449135
Test2=1.002777154
Test3=.9973126731
Test4=1

Test2 and Test3 are very close to what I'd expect (within floating point constraints) but I'd expect Test1 to be exactly 1. So what am I doing wrong?

Jeff
3 REPLIES 3
Peter_C
Rhodochrosite | Level 12
deleted_user
Not applicable
Well, that explains it! Thanks!

Jeff
ArtC
Rhodochrosite | Level 12
When the period includes a leap day, YRDIF adds the leap day and then averages it across four years (third arg is 'actual' or 'act/act'). If you are estimating a span of years then the value is off by a fraction of a day. This seems to be incrementally better than the (stop-start)/365.25 formula. Incrementally because either way the differences tend to be in the third decimal place.

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