How to increment SAS dates as new variables

Viewed 24

I would like to add a day to a SAS date and save that value as a new variable. I have these data:

data have;
    input ID $ date;
    datalines;
A 14610
B 13229
C 15644
D 14278
;
run;

And I would to end up with these data, with the new variables labelled for each iteration as below:

data want;
    input ID $ date date1 date2 date3;
    datalines;
A 14610 14611 14612 14613
B 13229 13230 13231 13232
C 15644 15645 15646 15647
D 14278 14279 14280 14281
;
run;

How can I accomplish this?

1 Answers

Try this

data have;
    input ID $ date;
    datalines;
A 14610
B 13229
C 15644
D 14278
;
run;

data want;
   set have;
   array d date1 - date3;
   do over d;
      d = date + _i_;
   end;
run;
Related