You don't really need the DURATION value if you use a "while (date<end_dt)" condition in the do loop:
data want;
format START_DT END_DT DATE date9.;
START_DT = '19APR2018'd;
EVENT_DAY_OF_MONTH = 6;
END_DT = '05JAN2019'd;
/** don't need: DURATION = intck('month',START_DT,END_DT)*2; */
date=start_dt; output;
do while (date<end_dt);
date=intnx('month',date,0,'E'); if date<end_dt then output;
date=min(end_dt,date+event_day_of_month); output;
end;
run;
Edited note: The other thing this program avoids is the MDY function. Since underlying date values are just the number of days after 01jan1960 (or before in the case of negative values), you merely need to add EVENT_DAY_OF_MONTH to the date value representing the end of the previous month. The only exception would be if EVENT_DAY_OF_MONTH is greater than the day-of-month in END_DT. Hence the MIN function.
Second editted note: I ran a test with END_DT=15JAN2019 and EVENT_DAY_OF_MONTH=6. It generated '06jan2019','31'jan2019', followed by the '15JAN2019'. Assuming the op would want to drop the 31jan2019, I corrected the code. You can see the new "if date<end_dt then" preceding one of the output statements. @_Zack_ : If I misinterpreted your expectation for END_DT=15JAN2019 and EVENT_DAY_OF_MONTH=6, please state what you would want.
... View more