How to calculate number of years and number of days between 2 dates;
How to calculate number of years and number of days between 2 dates; Exploring the yrdif and datdif functions in SAS as well as INTCK function: There are several ways to calculate the number of years between two dates and out of all the methods, YRDIF function results the most accurate value. Syntax: ageinyrs = YRDIF(birthdate, enddate, ' act/act '); ag_indays = DATDIF(birthdate, enddate, ' act/act '); “ act/act ” will gives us the actual interval between the two dates. The YRDIF function returns the calculated years between two SAS date values. The returned value will be a precise calculation, including multiple decimal places. Whereas with INTCK function will just give the rounded value like 10, 11 and not like 10.2 and 11.5. Syntax: Using YRDIF function: To know the interval between two dates in Years: data _null_; sdate=" 12mar1998 "d; edate=" 12jun2008 "d; years=yrdif(sdate,edate, 'act/act' ); put years ; run ; ...