Calcite | Level 5

## AGE CALCULATION

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.

8 REPLIES 8
Calcite | Level 5

## Calculate Age from birthdate to a specific year

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.

Diamond | Level 26

## Re: Calculate Age from birthdate to a specific year

DO NOT REPLY HERE

--
Paige Miller
Diamond | Level 26

## Re: AGE CALCULATION

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?

--
Paige Miller
Calcite | Level 5

## Re: AGE CALCULATION

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
Super User

## Re: AGE CALCULATION

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.

PROC Star

## Re: AGE CALCULATION

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.

Super User

## Re: AGE CALCULATION

@prjadhav00 Please note that I've merged your two posts into one.

PROC Star

## Re: AGE CALCULATION

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Discussion stats
• 8 replies
• 1614 views
• 0 likes
• 6 in conversation