Do NOT format macro variables that contain dates (unless you want to use them in titles or labels. which does not appear to be the case here as you want to use this macro variable in a data step). See Maxim 28.
%let offmnth = %sysfunc(intnx(month, %sysfunc(today()), -1));
data test&offmnth;
a= &offmnth;
put 'SAS date=' a;
put 'formatted date=' a date9.;
put 'formatted date=' a ddmmyyn6.;
run;
For example, since we are now as of time of writing in June 2022, I would want 010522 NOT 23767.
Unless you have some strict requirement, do not use 2 digit years, use 4 digit years, in which case use format ddmmyyn8.
SAS Dates are recorded in the number of days since 01JAN1960, and so you DO want 23767, which will work properly when you perform any aritmetic or logical operations in the DATA step, and can be made to appear as an actual date by using a format.
... View more