The code
age = intck('year', date2, date1);
will not always produce the result you might expect, because what it counts is the number of occurences of January 1 between the two dates:
69 data _null_;
70 years = intck('year', '31dec2019'd, '01jan2020'd);
71 put years=;
72 run;
years=1
Use of the CONTINUOUS option might produce the result you want:
data _null_;
years = intck('year', '31dec2019'd, '01jan2020'd, 'continuous');
put years=;
run;
The traditional method of calculating age in SAS, attributed to Billy Kreuter, is
age = floor(( intck( 'month', dob, death) - ( day(death) < day(dob)))/ 12);
<https://www.lexjansen.com/pharmasug/2011/CC/PharmaSUG-2011-CC20.pdf>
There's a lazy method that just takes the difference in days and divides by 365.25. Please don't use that method.
... View more