Ok, to just to be clear what you are trying to achieve: You have a macro variable P containing a date-formatted value (e.g, 01JAN2017) You have another macro variable D, which may contain a number, a missing (period) or be null. If D is a number, it represents a number of months. If D contains a number, you want to adjust the date value of P by the number of months in D. So how to check what's in D.. I used the ANYDIGIT() function.. The only fiddly bit was having nested %SYSFUNC() macro functions in the final calculation.. %macro MyAdjust(P_Old,D);
%local P_New;
%if %sysfunc(anydigit(%str(&d))) %then %let P_New = %sysfunc(intnx(month,%sysfunc(today()),&D.-1,BEGINNING),date9.);
%put P_Old:&P_Old P_New:&P_New;
%mend;
%MyAdjust(01JAN2017,1);
%MyAdjust(01JAN2017,0);
%MyAdjust(01JAN2017,12);
%MyAdjust(01JAN2017,.);
%MyAdjust(01JAN2017,); P_Old:01JAN2017 P_New:01APR2017 P_Old:01JAN2017 P_New:01MAR2017 P_Old:01JAN2017 P_New:01MAR2018 P_Old:01JAN2017 P_New: P_Old:01JAN2017 P_New: It just won't work for negative values of D because the negative sign counts as non-digit.
... View more