How about this?
data have;
infile cards dsd dlm=',';
attrib start_date end_date length=4 informat=date9. format=monyy7.;
attrib interval length=3;
input start_date
end_date
interval;
cards;
01JAN2001,31DEC2002,6
;
run;
data want;
set have;
length time_period $ 17;
do i = start_date to end_date by interval * 31;
i = intnx('month', i, 0, 'b');
j = intnx('month', i, interval - 1, 'b');
time_period = translate(catx(' - ', putn(i, 'mmyy7.'), putn(j, 'mmyy7.')), '/', 'M');
output;
end;
keep time_period;
run;
The format mmyy returns mmMyyyy, so the translate function swaps that out for a slash. I could have used something cleverer than interval * 31, but since I reset i to the beginning of the incremented month on the very next line, this will always work; sometimes (often) it's best to keep it simple, and it's easily clear enough what's going on.
... View more