First thing is to verify that you date variables actually contain SAS date values. Then adding 30 days is pretty trivial.
Here's one way to create date groups as indicated. Because I am way too lazy to write long lists of variables that are hard to use
I renamed them start_M1 to start_M36 to simplify the creation and format assignment statements. The use arrays to create the boundary values. The pairs are not adjacent in the data because of the creation. If you really want them paired then you'll have to write something with all 72 variables in the order you want them.
data want;
informat cust_id $3. purchase_dt anydtdte.;
input cust_id purchase_dt;
format purchase_dt ;
array start start_M1-start_M36 ;
array end end_M1 - end_M36 ;
do i = 1 to 36;
if i=1 then do;
start[i]=purchase_dt;
end;
else do;
start[i]=end[i-1]+1;
end;
end[i] = start[i]+30;
end;
format start_M: end_M: date11.;
datalines;
001 12-Aug-14
002 21-Aug-14
003 2-Sep-14
004 4-Aug-14
005 9-Aug-14
;
run;
With that behind. I might suggest that you might do better with:
data want;
informat cust_id $3. purchase_dt anydtdte.;
input cust_id purchase_dt;
format purchase_dt date11.;
do Month = 1 to 36;
if Month=1 then do;
start=purchase_dt;
end;
else do;
start=end+1;
end;
end = start+30;
output;
end;
format start end date11.;
datalines;
001 12-Aug-14
002 21-Aug-14
003 2-Sep-14
004 4-Aug-14
005 9-Aug-14
;
run;
For many purposes.
... View more