## Age from BirthDate!

Solved
Super Contributor
Posts: 1,041

# Age from BirthDate!

Hi,

I have a date(DOB) and I want to know the years?

example:

DOB

12sep1982

I want something like(probably not in decimals)

AGE:

31

Thanks

Accepted Solutions
Solution
‎09-12-2013 09:24 PM
Regular Contributor
Posts: 249

## Re: Age from BirthDate!

[ Edited ]
Posted in reply to robertrao

You may like to read this -

Age Is Just a Number: Accurately Calculating Integer and Continuous Age by Sara Adams and Chris Colby, ICON Clinical Research, San Francisco, CA

The paper discusses integer age and continuous age -- and methods to calculate each.

And from @Tom:

If have SAS 9.3 or higher use YRDIF(dob,eventdt,'AGE'); [article with examples here]

All Replies
Super Contributor
Posts: 1,636

## Re: Age from BirthDate!

Posted in reply to robertrao

data have;

format dob date9.;

input dob date9.;

cards;

02sep1982

;

data want;

set have;

age=int((today()-dob)/365.25);

proc print;run;

Super Contributor
Posts: 312

## Re: Age from BirthDate!

Posted in reply to robertrao

The INTCK function measures the number of intervals between 2 dates.

DATA WANT;

SET HAVE;

AGE = INTCK('YEAR',DOB,TODAY());

RUN;

Respected Advisor
Posts: 4,736

## Re: Age from BirthDate!

Posted in reply to Scott_Mitchell

Using INTCK() the following would return '1' which I believe is not what you would expect to get as age:

INTCK('YEAR','31DEC2012'd,'01JAN2013'd);

Super Contributor
Posts: 312

## Re: Age from BirthDate!

Agreed Patrick.  Once I read your suggestion regarding YRDIF I remembered that INTCK was the incorrect solution for this scenario.

Frequent Contributor
Posts: 81

## Re: Age from BirthDate!

Posted in reply to Scott_Mitchell
Hi,
When I use the INTCK function I get a message (window is full and must be cleared. Select:
F to file.
P to Print
S to save or
C to clear the window without saving

Any insights why this is happening?
Respected Advisor
Posts: 4,736

## Re: Age from BirthDate!

Posted in reply to robertrao

age=YRDIF(DoB, today(), 'ACT/ACT') ;

Solution
‎09-12-2013 09:24 PM
Regular Contributor
Posts: 249

## Re: Age from BirthDate!

[ Edited ]
Posted in reply to robertrao

You may like to read this -

Age Is Just a Number: Accurately Calculating Integer and Continuous Age by Sara Adams and Chris Colby, ICON Clinical Research, San Francisco, CA

The paper discusses integer age and continuous age -- and methods to calculate each.

And from @Tom:

If have SAS 9.3 or higher use YRDIF(dob,eventdt,'AGE'); [article with examples here]

Frequent Contributor
Posts: 81

## Re: Age from BirthDate!

Hi,
When I use the INTCK fuction I get a message (window is full and must be cleared. Select:
F to file.
P to Print
S to save or
C to clear the window without saving

Any insights why this is happening?
Super User
Posts: 8,115

## Re: Age from BirthDate!

Posted in reply to robertrao
Occasional Contributor
Posts: 7

## Re: Age from BirthDate!

Posted in reply to robertrao

I am trying to calculte age as well using SAS 9.4.

this is the code i have used but the age is off by one year. How to correct it?

*creating Mat_age*/;
MAT_AGE = (int(new_DOB - new_MomDOB)/365.25);

Community Manager
Posts: 3,432

## Re: Age from BirthDate!

Posted in reply to new_sas2015

I think you intended to apply the INT function to the entire computed value, so you need to move a paren:

``MAT_AGE = int( (new_DOB - new_MomDOB) /365.25);``

But the better way (I think) is to use YRDIF with the AGE modifier:

``MAT_AGE = yrdif(new_DOB, new_MomDOB,'AGE');``
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
• 11 replies
• 29740 views
• 9 likes
• 9 in conversation