1
votes

I'm looking for the SAS code to create "new" rows for each days between two dates. E.g. I have the original dataset containing:

Num. StartDate EndDate  Tag
5      13JUN2017 25NOV2017  1
6      1JAN2017 4MAR2017   5 
...

etc. and I need to transpose this dataset with

Num. Day           TAG
5      13JUN2017     1
5      14JUN2017     1
... 
5      25NOV2017     1
6      1JAN2017      5
...
6      4MAR2017      5
...

Can anyone help? Thanks in advance!

1
Already found it! - ClS
Place that discovery into an answer below, and accept it. Then we won't navigate into this question expecting someone needs help still. Please do this. Others looking for it may also thank you. - Paul Maxwell

1 Answers

1
votes

Try using do while

data have;
input num startdate enddate tag;
informat startdate date9. enddate date9.;
format startdate date9. enddate date9.;
cards;
5 13jun2017 25nov2017 1
6 01jan2017 04mar2017 5
;
run;

data want; 
set have;
format next_due_date date9.;
next_due_date = startdate;
do while (enddate > next_due_date);
next_due_date = intnx("day",next_due_date,1);   
output;
end;
run;

Let me know in case of any queries.