Quartz | Level 8

## 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

1 ACCEPTED SOLUTION

Accepted Solutions
Barite | Level 11

## Re: Age from BirthDate!

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]

SAS instructor @D_Dunlap covers this topic and many other Date function FAQs in this video.

12 REPLIES 12
Lapis Lazuli | Level 10

## Re: Age from BirthDate!

data have;

format dob date9.;

input dob date9.;

cards;

02sep1982

;

data want;

set have;

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

proc print;run;

Quartz | Level 8

## Re: Age from BirthDate!

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

DATA WANT;

SET HAVE;

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

RUN;

Opal | Level 21

## Re: Age from BirthDate!

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);

Quartz | Level 8

## Re: Age from BirthDate!

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

Calcite | Level 5

## Re: Age from BirthDate!

I believe this happens because the alignment option in the INTCK function defaults to DISCRETE, which counts interval boundaries in between two dates, rather than CONTINUOUS, which counts full intervals in between dates, shifted to the start date.

The following code should work:

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

See here for details:

http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p1md4mx2crz...

Quartz | Level 8

## Re: Age from BirthDate!

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?
Opal | Level 21

## Re: Age from BirthDate!

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

Barite | Level 11

## Re: Age from BirthDate!

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]

SAS instructor @D_Dunlap covers this topic and many other Date function FAQs in this video.

Quartz | Level 8

## 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

## Re: Age from BirthDate!

Calcite | Level 5

## Re: Age from BirthDate!

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

## Re: Age from BirthDate!

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');``
Discussion stats
• 12 replies
• 61514 views
• 12 likes
• 10 in conversation