BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASdevAnneMarie
Barite | Level 11

Hello Experts,

 

I'm wondering if it is possible to calculate the age in the middle of the year. At the end of the year I have :

floor(YRDIF(d_birth, mdy(12,31,2025),"AGE"))

  How to calculate the age on 6/30 ?

 

Thank you !

1 ACCEPTED SOLUTION

Accepted Solutions
Kathryn_SAS
SAS Employee

If you want the middle of the year, you can change the MDY function to the following:

age=floor(YRDIF(d_birth, mdy(6,30,2025),"AGE"));

View solution in original post

3 REPLIES 3
Kathryn_SAS
SAS Employee

If you want the middle of the year, you can change the MDY function to the following:

age=floor(YRDIF(d_birth, mdy(6,30,2025),"AGE"));
Ksharp
Super User

I don't understand your question. Could you post some data and desired output ?

Here might be what you are looking for ?

data x;
do d_birth='01jan2024'd to '02dec2025'd by 30;
 middle_year=intnx('year.7',date(),0,'e');
 want=floor(YRDIF(d_birth,middle_year,"AGE"));
 output;
end;
format d_birth middle_year  date9.;
run;

proc print;run;

Ksharp_0-1767944111310.png

 

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 save with the early bird rate—just $795!

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
  • 3 replies
  • 170 views
  • 3 likes
  • 4 in conversation