BookmarkSubscribeRSS Feed
SASdevAnneMarie
Barite | Level 11

Hello Experts,

I'm calclulating the age between 2 dates as  int(yrdif(datepart(D_NAISSANCE),datepart(d_2),'ACTUAL')), I'm wondering how to take into consideration the leap year (366 days)?

 

Thank you !

2 REPLIES 2
maguiremq
SAS Super FREQ

INTCK and INTNX (INTNX is what you would want) takes care of leap years.

 

https://blogs.sas.com/content/iml/2017/05/15/intck-intnx-intervals-sas.html

ballardw
Super User

Suggestion: Pick dates that you know the expected result for "age". Put those into the function and see the result.

 

If you don't know how to put a specific data the structure is 'ddMONyyyyy'd where MON is the 3-letter abbreviation of the month.

 

So yrdif ('02JAN2015'd, '15JUL2023'd) is what yrdif returns for a date of birth of 02JAN2015 with age evaluated on 15Jul2023.

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
  • 2 replies
  • 1449 views
  • 0 likes
  • 3 in conversation