Hi, Some of the other answers provided a method for calculating an approximate age in months. In some situations the result will be in error. Your vaccine study monitors will probably not like an approximate age. Since we are programming computers it's possible to program an exact solution that is almost always correct. One will use SAS code like: age_months = floor((intck('month',birthdate,vacine_date)-(day(vacine_date) < day(birthdate)))); Here's a sample program showing how to use it: data day_month_year; *** data step to get data into day_month_year SAS dataset;
*** there are several ways to do this input, this works in traditional SAS;
infile datalines;
input day month year birthdate date9.;
datalines
31 01 1998 01dec1990
02 08 2003 18jan1993
15 12 2001 15aug1991
... the rest of the 550 subjects
;;
run;
data ages_months; *** new dataset with calculated vars;
set day_month_year; *** read in dataset created above;
vacine_date = mdy(month,day,year); *** use mdy function to create SAS date variable;
age_months = floor((intck('month',birthdate,vacine_date)-(day(vacine_date) < day(birthdate))));
*** line above calculates age in months using floor, intck, and day functions;
run;
proc print
data = ages_months;
run;
... View more