SAS calculate age based on year of birth and a complete end date

numeric, sas

Solution

The MDY function will make a date from numerics. So for example,

datevar = mdy(1,1,yearvar);

will make a date variable for Jan 1, (year). (That's the default when only year is known).

So to get age difference, you can use

age=yrdif(diagdate,mdy(1,1,yearvar),'AGE');

Problem

I have a data set that only gives year of birth. I want to calculate age based on when an individual was diagnosed with diabetes. For example I have a diagnosis date of 31Jan2002 and a year of birth 1964. The yrdob variable is NOT a date variable - it is only numeric and every time I try to make it a date variable so I can use the yrdif function it makes all of the years 1965 instead of recognizing the yrdob as a year, not the number of days after 1960. Therefore my question is: How do I take a numeric variable that is meant to be interpreted at face value (1965 means the year 1965 - not one thousand sixty-five) and make it a date variable so I can use the yrdif function to calculate age?

Original source