I don't understand why you're calculating fy and using it in IF-ELSE statement. I believe there would be some good reason but I can't tell without knowing an input data and no understanding exact requirement.
Though it seems you're only interested in current FY year to calculate age. If so then you can have only one following IF statement. You just need to have dynamic current year to compare with your FY. And replace hard-coded last day of the year date with dynamic date using intnx('year',today(),0,'E')
if fy = year(today()) then age = floor((intck('month',birthday,intnx('year',today(),0,'E'))-(day(intnx('year',today(),0,'E')) < day(birthday)))/12);
In case if you have complex input dataset and want to use sas macro then here one simple example:
/* Macro that calculate age */
%macro age(date, birth);
floor((intck('month', &birth, &date) - (day(&date) < day(&birth))) / 12)
%mend age;
data _NULL_;
Birthday='11NOV1990'd;
/* i assume you have birthday date variable in the input data set hence can be easily replaced */
fy=2023;
/* i assume you have fy variable in the input data set hence can be easily replaced */
LastDayOftheYear=intnx('year', today(), 0, 'E');
if fy=year(today()) then
age=%age(LastDayOftheYear, Birthday);
put Birthday=date9. LastDayOftheYear=date9.;
put age=;
run;
... View more