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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.