Hi, I'm trying to create multiple variables based on conditions with date as their suffix. The following code only generate one variable from the end date. How do I make it generate multiple variables based on dates in between the end and start date, and keep them on master2? %macro dis_status(startdate,enddate);
%let sasstart = %sysfunc(inputn(%substr(&startdate,3,6),yymmdd6.));
%put &sasstart;
%let sasend = %sysfunc(inputn(%substr(&enddate,3,6),yymmdd6.));
%put &sasend;
%do sasdate=&sasstart %to &sasend;
%let date= %sysfunc(putn(&sasdate,yymmdd6.));
%put &date;
data master2;
set master1;
if code22_&date. in ('1','2','3','4')
then status22_&date. = "G ";
else if CODE22_&date. in ('5','6')
then status22_&date. = "IE";
else if CODE22_&date. in ('7','8')
then status_&date. = "NR";
else CODE22 in ('10,'11')
then status_&date. = "UE";
run;
%end;
%mend;
%dis_status(20220608,20221019); Thanks! Add Tags
... View more