Hi,
I'm trying to get the difference in Years between two dates at the end of each month end date.
MembershipDate: which is a Datetime format and
I have a parameter I reference throughout my code to be the month end date:
%let cur_mth_end = '31Jan10'd.
I used the function
Tenure = Datdif (MembershipDate, &cur_mth_end, 'act/act') / 365 ;
but I get the note:
Invalid argument to function DatDif
I'm pretty sure its because MembershipDate is a datetime format, but not sure how to fix this.
Thanks for your help.
Thanks for your help, I used INTCK to solve it.
To convert a datetime to date use the datepart function.
You might want to look up the intck function which calculates some date difference and you can also customize the alignment in that function to 'end' of the month/year which seems what you're looking for.
How about if you wrap MembershipDate within a datepart function? e.g.
Tenure = Datdif (datepart(MembershipDate), &cur_mth_end, 'act/act') / 365 ;
I've tried
Tenure = Datdif (datepart(MembershipDate), &cur_mth_end, 'act/act') / 365
but i'm still getting the error.
Post your log, where you're using the mprint option.
Thanks for your help, I used INTCK to solve it.
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!
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.