Why not just leave them as DATE values and attach format to print the values in that YYYYMM style?
data two;
set want;
new_dt = active_dt ;
old_dt = intnx('month',active_dt,-1);
format new_dt old_dt yymmn6.;
run;
If you really need to create those integers in the YYY,YMM style then remember that the INTNX() interval MONTH works with DATE values. Since you seem to have a date valued variable (otherwise the DATE9 format would print the values as gibberish) just use that variable with your INTNX() call.
data two;
set want;
new_dt = input(put(active_dt,yymmn6.),6.);
old_dt = input(put(intnx('month',active_dt,-1),yymmn6.),6.);
run;
If you only have the YYY,YMM integers then convert them into date values first.
Example:
185 data test;
186 new_dt=202403;
187 date_value=input(put(new_dt,z6.),yymmn6.);
188 format date_value yymmdd10.;
189 put (_all_) (=);
190 run;
new_dt=202403 date_value=2024-03-01
... View more