Hi I am trying to find the years between the two dates.
date1 date2
16MAR2011 10JAN1964
difference=date1-date2
this gives me in seconds....
How can I get years??????
Thanks
Not sure, I am using the same and getting 47.
data have;
date1='16MAR2011'd;
date2='10JAN1964'd;
difference=intck('year',date2,date1);
run;
data have;
date1='16MAR2011'd;
date2='10JAN1964'd;
difference=intck('year',date2,date1);
run;
difference=intck('year',date2,date1);
I tried the above and it gives me negative age in years
Do I need to do:
difference=intck('year',date1,date2);
Thanks
What is your date1?
date1=16MAR2011
date2=10JAN1964
Not sure, I am using the same and getting 47.
data have;
date1='16MAR2011'd;
date2='10JAN1964'd;
difference=intck('year',date2,date1);
run;
Your order is different the OP.
If that gives seconds you have DATETIME value, it should be Days if the values are actual SAS dates.
Do you need years as in and date in 2011 and any date in 1964 = 47 or do you need to calculate as if a calendar age?
Hi Ballard,
I have SAS dates and not datetimes. sorry for the confusion.
I think if we can get to the 47 that should be fine
also please let me know how to do the calendar age ....good to know
Thanks
Calculating age: SAS(R) 9.3 Functions and CALL Routines: Reference
difference=yrdif (date2,date1);
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.