SAS ‘DO’ Loops

The DO Statement in SAS for looping or iteration is used along with while and until special cases. Also, you need to tell SAS whether you need the output of each iteration, for that you need to include the output; statement. You always need to finish it by keyword end;

Variables on which DO is performed are usually defined as i or j. DO statements can also be nested.

Data DOLOOP;
 DO i = 1 to 9 by 2;
      output;
end;
run;
                           /*until Special Case*/
Data DOLOOP;
 DO i = 0 to 20 by 3 until (i=9);
      output;
end;
run;