Please try the below code
in %put you should use &&date&i however you used &date&i
also if you want to create the macro variables as &date1 and &date2, we need to use the call symputx in the datastep which i have done in the code below.
%let YYMMDD1=200421;
%let YYMMDD2=200420;
%macro mmacro;
%do i=1 %TO 2;
Data _null_;
Y&i=input(SUBSTR(COMPRESS(&&YYMMDD&i.),1,2),best.);
M&i.=input(SUBSTR(COMPRESS(&&YYMMDD&i.),3,2),best.);
D&i.=input(SUBSTR(COMPRESS(&&YYMMDD&i.),5,2),best.);
call symputx("date&i.",MDY(M&i.,D&i.,Y&i.));
Run;
%put &&date&i.;
%end;
%mend mmacro;
%mmacro;
... View more