The following example mimics your first row:-
data example;
Name = "Don";
birth_day = "02-Mar";
birth = "1913";
death_day = "01-Nov";
death = "1998";
run;
data example_with_age;
set example;
length death_date birth_date 5 age 3;
format death_date birth_date date11. age 4.1;
death_date = input(cats(death_day,'-', death), date11.);
birth_date = input(cats(birth_day,'-', birth), date11.);
age = yrdif(birth_date, death_date,'AGE'); ** The 'AGE' part only works in SAS 9.3+!!;
run;
I've assumed your birth and death variables are character. If they're numeric, you should surround them with a put
statement in the input
rows.
I've been lazy with calcalating age by using a feature in newer versions of SAS - it's a surprising hassle calculating age when using full dates. If you're using an older SAS version, let me know in a comment and I'll add the older method of calculating the age.