Macro variables containing date values, date/time values or time values should NOT be formatted (Maxim 28) for arithmetic or logical operations.
data _null_;
call symputx('tday',today());
run;
%put &tday ;
data test;
my_date = INTNX('MONTH',&tday,1,'SAMEDAY') ;
format my_date mmddyy8.;
run;
Why? Because the INTNX function cannot work with &tday as you have created it, because the value 02/18/22 is interpreted as 2 divided by 18 divided by 22. However, the unformatted value of &tday (as I have programmed it) is 22694, which is indeed exactly what INTNX needs, this is interpreted as a valid legal SAS date. (Valid legal SAS dates are the number of days since 01JAN1960, that's what 22694 represents).
Please, for clarity, you do not have a macro in your code. You have a macro variable. These are not the same. Please do not refer to macro variables as macros or vice versa, this is incorrect. Clarity is always good.
Adding: it is not the fault of the macro variable here, as your title implies ... it is a programming error. A good method to use is to first write code without macro variables and get that to work properly, and then creating code that works with macro variables should be relatively easy. Most people don't do this, and they should! But if your code doesn't work without macro variables, then it will never work with macro variables.
... View more