Don't apply a format to a date, datetime or time macro-variable if you want to use in calculations.
Try
%let wanted = %sysfunc(intnx(dtyear, %sysfunc(datetime()), -1, s), e8601dt24.3);
or if you need the variable date (bad name for a variable not containing a date, but a datetime-value):
%let date = %sysfunc(datetime());
%let want = %sysfunc(intnx(dtyear, &date., -1, s), e8601dt24.3);
%put &=want;
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.