Solved
Contributor
Posts: 41

# INTCK to compute age

Method 1: Age=FLOOR((INTCK('month',dob,eventdate)-(day(eventdate)<day(dob)))/12)

Method 2: Age= INTCK('year',dob,eventdate,"Continuous")

Hi I was wondering if two methods above have the same function on calculating Age based on DOB.

Thanks a lot

Accepted Solutions
Solution
‎05-18-2016 04:30 PM
Posts: 5,529

## Re: INTCK to compute age

YRDIF actually accepts "AGE" as third argument and returns an age with a fractional part. So

floor(YRDIF(birthDate, today(),"AGE"))

is another way to get the current age in years.

PG

All Replies
Posts: 5,529

## Re: INTCK to compute age

Posted in reply to fbl204653

No, the results will differ sometimes.

Method 2 will give you the exact age.

Method 1 will sometimes give you the wrong result when eventdate occurs in the same month as dob.

PG
Contributor
Posts: 41

## Re: INTCK to compute age

Hi PG,

I tried one example, somehow, two methods gave me the same result (see age and age2).

%macro age(date,birth);
floor ((intck('month',&birth,&date) - (day(&date) < day(&birth))) / 12)
%mend age;

data c;
WeddingDay='19may2000'd;
Today='18MAY2016'd;
age=%age(Today,WeddingDay);
age1=intck('year',WeddingDay,Today,"D");
age2=intck('year',WeddingDay,Today,"C");
run;

Super User
Posts: 13,542

## Re: INTCK to compute age

Posted in reply to fbl204653

May also want to investigate YRDIF with the 'ACT/ACT' option.

Solution
‎05-18-2016 04:30 PM
Posts: 5,529

## Re: INTCK to compute age

YRDIF actually accepts "AGE" as third argument and returns an age with a fractional part. So

floor(YRDIF(birthDate, today(),"AGE"))

is another way to get the current age in years.

PG
Contributor
Posts: 41

## Re: INTCK to compute age

thanks a lot
🔒 This topic is solved and locked.

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

Discussion stats
• 5 replies
• 1493 views
• 3 likes
• 3 in conversation