0
votes

I am working on a piece of code to take an array of dates and then out put an array of all dates that are within a given buffer of the dates within the original dates vector.

My plan is to use 2 nested do loops to loop through the original array of dates and each time add/subtract the buffer and then use data set to add these two observations to the original set.

I have been using the following code, but I end up in an infinite loop and SAS crashes.

%let buffer = 3;     
data dates_with_buffer; 
   do i = -1*&buffer. to &buffer.; 
      do j = 1 to 14; 
         set original_dates point = j; 
         output_dates = dates + &buffer.; 
         output; 
      end; 
   end; 
run;
1
could u pls provide an example of the input data set and the desired output. - Altons

1 Answers

1
votes

When you use point= on a set statement, you need to include a stop statement as well to prevent an infinite loop. Try this:

%let buffer = 3;     
data dates_with_buffer; 
   do i = -1*&buffer. to &buffer.; 
      do j = 1 to 14; 
         set original_dates point = j; 
         output_dates = dates + &buffer.; 
         output; 
      end; 
   end; 
   stop;
run;