First, @raajdesaii , I will leave it to you to add the Visitdate column as you would like it. Aside from that, this class of problem is interesting to me because I face it in my work too. I think this is the way I handle this kind of problem. It needs these five steps, I say, if for anything, to be able understand what we had programmed when we look back six months later.
data IDs;
set have (Keep=ID Startdate Enddate);
by ID;
if first.ID;
run;
data AllNewDates (sortedby=ID Newdate);
set IDs;
Newdate=intnx('month',Startdate,0);
do while (Newdate<Enddate);
Count=0;
output;
Newdate=intnx('month',Newdate,1);
end;
run;
data Newdates0 (Keep=ID Newdate);
set have (Keep=ID Visitdate);
Newdate=intnx('month',Visitdate,0);
format Newdate date9.;
run;
proc freq data=Newdates0;
by ID;
table Newdate / out=Newdates(drop=PERCENT) noprint;
format Newdate date9.;
run;
data want;
update AllNewDates Newdates;
by ID Newdate;
format Newdate monyy7.;
run;
... View more