BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Nietzsche
Lapis Lazuli | Level 10

the DATDIF(date1,date2,'ACT/ACT') gives the same answer as a date2-date1. What is the point of learning this function?

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@Nietzsche wrote:

Well, it is in the Base exam prep guide, the YRDIF is useful, but I fail to see the purpose of learning this function for the base exam.


Since the DATDIF and YRDIF involve some standard basis values used in specific financial calculations. If you work in the industries that use those basis value frequently then they are helpful. Otherwise you have to write code that simulates the effect and from a certain amount of experience many people will miss something related to leap years when implementing their own code.

View solution in original post

7 REPLIES 7
PeterClemmensen
Tourmaline | Level 20

You are correct that in the 'ACT/ACT' case, the two are similar. However browsing the DATDIF Function Doc, you can see that there are other arguments you can use as the basis argument. Therefore, the two are not similar.

 

Whether or not you should learn it is hard to answer, but you will probably rarely use it. I have hardly ever used it at least 🙂

Nietzsche
Lapis Lazuli | Level 10

Well, it is in the Base exam prep guide, the YRDIF is useful, but I fail to see the purpose of learning this function for the base exam.

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).
PeterClemmensen
Tourmaline | Level 20

I've never done the course or exam. So if the function is part of the exam, then learn it. If your question is 'Are Datdif / Yrdif Function(s) used frequently in real life?', then the answer is No 🙂

ballardw
Super User

@Nietzsche wrote:

Well, it is in the Base exam prep guide, the YRDIF is useful, but I fail to see the purpose of learning this function for the base exam.


Since the DATDIF and YRDIF involve some standard basis values used in specific financial calculations. If you work in the industries that use those basis value frequently then they are helpful. Otherwise you have to write code that simulates the effect and from a certain amount of experience many people will miss something related to leap years when implementing their own code.

ChrisHemedinger
Community Manager

DATDIF, YRDIF, INTCK and INTNX are part of the pantheon of SAS date/datetime functions that are (as far I've seen) unequaled in almost any other programming language. As @ballardw points out, many of them are rooted in the need for very accurate rules-based calculations for financial applications...but their uses go well beyond these.

 

I recommend this tutorial from @derekmor54 -- less than 10 minutes and you'll see some of the many applications of these functions.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
SASKiwi
PROC Star

@Nietzsche - With all due respect if you think your SAS training course content should align exactly with real world usefulness then I think you are bound to be disappointed. Do what is necessary to pass the exam. You never know whether a particular technique or function will come in handy or not in your career.

Patrick
Opal | Level 21

@Nietzsche Not hard to learn and you don't need to memorize all the details (as also true for other functions). It's valuable though to know that these functions exist and what they can do for you as this might save you a lot of time and coding in the future.

Datdif() can for example be very useful with basis '30/360' if you have to calculate interest the way banks are doing it, yrdiff() is really great and simple to use if you want to calculate age.

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 7 replies
  • 920 views
  • 3 likes
  • 6 in conversation