BookmarkSubscribeRSS Feed
prjadhav00
Calcite | Level 5

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
prjadhav00
Calcite | Level 5

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.

PaigeMiller
Diamond | Level 26

DUPLICATE THREAD

 

DO NOT REPLY HERE

 

Reply at: https://communities.sas.com/t5/SAS-Programming/AGE-CALCULATION/m-p/527422#M143779

--
Paige Miller
PaigeMiller
Diamond | Level 26

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
prjadhav00
Calcite | Level 5
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
ballardw
Super User

@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.

SASKiwi
PROC Star

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. 

Reeza
Super User

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

mkeintz
PROC Star

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

--------------------------

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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