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 !
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"));
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"));
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;
Use
6,30
instead of
12,31
in the MDY function?
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.
Ready to level-up your skills? Choose your own adventure.