the DATDIF(date1,date2,'ACT/ACT') gives the same answer as a date2-date1. What is the point of learning this function?
@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.
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 🙂
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.
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 🙂
@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.
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.
@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.
@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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.