@davies wrote:
Hi,
Thanks all for the quick replies! As luck would have it, just after I posted this I adapted this code to account for dates: https://communities.sas.com/t5/Statistical-Procedures/How-to-split-record-into-multiple-rows-one-row-per-month-year/td-p/249306
In the end, I did this, but your way seems much more efficient, I'll try that!
Thanks again!
data want; set have; date=StartDate; if StartDate lt EndDate then do while (date lt EndDate); day=day(date); month=month(date); year=year(date); output; date=intnx('day',date,1); end; drop date; run;
Behavior difference at beginning of the interval if the start = end. With the DO loop the it will execute once. The DO WHILE as shown would not execute.
I would guess the above code was written by someone either less familiar with SAS DO loop construct using start and end variable values or from a programming language/school that does everything with DO WHILE/UNTIL and not iterated loops for some other reason..
... View more