DATEDIFF will give you the exact difference in the requested units with truncation. So that matches the age calculation that applies if you are trying to buy a drink or get a driver's license. However, that is not itself a date: it is a duration and, therefore, would not have a date format.
If you want a datelike form, you can compute the parts using the mod function, e.g.,
compute years = mod(delta, 365).
compute resid1 = delta - years * 365.
compute months = mod(resid1, 31).
etc.
where delta is the datediff value with "days" as the unit.
But you have to decide how long a month is. DATEDIFF takes the calendar into account, but the subsequent calculations use a fixed number of days for years and months.
You might also be interested in the DATESUM function, which adds a fixed number of units - days, months, whatever, to a date. It takes into account the actual unit lengths according to the calendar but still uses a constant for the number of units to add.
------------------------------
Jon Peck
------------------------------
Original Message:
Sent: Tue November 30, 2021 10:16 AM
From: xiaoqin Oezener-Wan
Subject: Chronological age
Hello
you can use DATEdiff function:
compute agechr=datediff(aw2, dob, 'days').
agechr is the days between aw2 and dob.
best regards,
------------------------------
xq
------------------------------