Hi all,
I'm trying to find the birth year for a dataset, but I'm solely provided with the birthday, birth month (numeric), and age. How would I tackle this problem?
Thanks!
So, I have a dataset that contains customer's birthday, birth month and their age. I'm trying to find the birthday of each customer, which includes their birth year. Any suggestions?
Please post examples of this data.
I sounds like you don't actually have the birthday as that would imply you know the year of birth.
So let's assume you mean that you just have the month of the year and day of the month. So something like this:
data have;
input age month day;
cards;
10 11 23
10 11 20
;
To use AGE to calculate the birthday you need to know the date at which the age was calculated. So let's assume it is the age as of today. So to find the year of birth just subtract the age from the year of the date. And then if the month/day of birth is after this point in the year you need to subtract one.
data want ;
set have;
date=today();
format date date9.;
year=year(date)-age;
if date < mdy(month,day,year(date)) then year=year-1;
run;
Obs age month day date year 1 10 11 23 22NOV2020 2009 2 10 11 20 22NOV2020 2010
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.