I am looking for AGE from a birthdate to a specific year(2008) .......................date formate is MMDDYYYY
so far my query, which giving me the age based on to todays date;
proc sql;
create table Cohort as
Select *, floor(YRDIF(BENE_BIRTH_DT, today(),"AGE")) as memberAge
Any suggestions or solutions are highly appreciated.
I am looking for AGE from a birthdate to a specific year(2008) .......................date formate is MMDDYYYY
so far my query, which giving me the age based on to todays date;
proc sql;
create table Cohort as
Select *, floor(YRDIF(BENE_BIRTH_DT, today(),"AGE")) as memberAge
Any suggestions or solutions are highly appreciated.
DUPLICATE THREAD
DO NOT REPLY HERE
Reply at: https://communities.sas.com/t5/SAS-Programming/AGE-CALCULATION/m-p/527422#M143779
The concept of age to a specific YEAR isn't really clear to me. You can compute age to a specific DATE, but as far as I know, age to a specific YEAR isn't defined.
So what is it that you want?
@prjadhav00 wrote:
Thanks for getting back to me.
suppose if a person birthday is 12/2/1956 I want to check how much is that
personage in 2008 or 2010 or any other year.
when I check it's giving me the age of that person based on Today's date
At what day in the year? Age is always dependent upon a given target date. If I am born on 31Dec 2000 I am not 20 years on 1Jan2020, 19 for legal purposes and 19.0027 for biological purposes. On 31Dec2020 I would be 20 years old.
The YRDIF function with two dates and the third parameter of 'AGE' will give you a continuous age. There are other approaches using the INTCK function but they all are going to want a date to evaluate an age, not just a year.
So how old would someone be during the WHOLE of 2008 or 2010 be if they were born on 12/2/1956? And is this date 2 Dec or 12 Feb?
This isn't a trick question. Ages are usually calculated as the number of years from the birth date to today's date. If you want a different calculation please tell us what that is.
@prjadhav00 Please note that I've merged your two posts into one.
I guess what you mean is what age will a person attain during a year. If so, then you simply want the age as of DEC 31 of that year. So for 2008, use the date literal for dec 31, 2008:
proc sql;
create table Cohort as
Select *, floor(YRDIF(BENE_BIRTH_DT,'31dec2008'd,"AGE")) as memberAge
...
Note I embedded the YRDIF function in the FLOOR function, assuming you want age as integers.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.