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.
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.
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.