BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
archibald
Obsidian | Level 7

 

 

Hi ,

I need to  calculate age at graduation.  I was wondering if  any of  the two methods below are appropriate and take care  leap years as well.

 

Method 1: AgeINTCK('year',dob,graduationdate,"C")

Method 2Age= (graduationdate-dob)/365.25

Thank you very much

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Isn't it a bit strange that one would have to resort to datestring formatting to calculate an age? The matter depends on a specific case: if you are born on the 29th of February (in a leap year, obviously), do you celebrate your birthday on the 28th of February or on the first of March, during non-leap years? If your answer is the former then your age is

 

intck("year", dob, event, "continuous")  /* birthday on the 28th during non-leap years */

 

otherwise, your age is

 

intck('year', dob, event) - (put(dob, mmddyy4.) > put(event, mmddyy4.))  /* birthday on March 1st during non-leap years */

 

Another option is to use function INT(YRDIF(dob, event, "AGE")). It considers that you will celebrate your birthday on the 28th, even on leap years.

 

PG

View solution in original post

5 REPLIES 5
Reeza
Super User

 

The recommended formula:

 

age = intck('year',dob,event) - (put(dob,mmddyy4.) > put(event,mmddyy4.)) ;

 

https://communities.sas.com/t5/SAS-in-Health-Care-Related/Calculating-Age-But-Not-Rounding-Up/td-p/1...

 

PGStats
Opal | Level 21

Isn't it a bit strange that one would have to resort to datestring formatting to calculate an age? The matter depends on a specific case: if you are born on the 29th of February (in a leap year, obviously), do you celebrate your birthday on the 28th of February or on the first of March, during non-leap years? If your answer is the former then your age is

 

intck("year", dob, event, "continuous")  /* birthday on the 28th during non-leap years */

 

otherwise, your age is

 

intck('year', dob, event) - (put(dob, mmddyy4.) > put(event, mmddyy4.))  /* birthday on March 1st during non-leap years */

 

Another option is to use function INT(YRDIF(dob, event, "AGE")). It considers that you will celebrate your birthday on the 28th, even on leap years.

 

PG
archibald
Obsidian | Level 7

This makes a lot sense.Thanks a lot!

archibald
Obsidian | Level 7

Great! Thank you very much

archibald
Obsidian | Level 7
Great! Thank you very much Reeza

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 17187 views
  • 4 likes
  • 3 in conversation