Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Programming Statements

DO Groups

A set of statements can be treated as a unit by putting them into a DO group, which starts with a DO statement and ends with an END statement. In this way, you can submit the entire group of statements for execution as a single unit. For some programming applications, you must use either a DO group or a module. For example, LINK and GOTO statements must be programmed inside of a DO group or a module.

The two principal uses of DO groups are

DO groups have the following general form:

DO ;
    additional statements
END ;

You can nest DO groups to any level, just like you nest IF-THEN/ELSE statements. The following is an example of nested DO groups:


      do;
		 		 statements;
		 		 do;
		 		 		 statements;
		 		 		 do;
		 		 		 		 statements;
		 		 		 end;
		 		 end;
		 end; 

It is good practice to indent the statements in DO groups, as shown abovein the preceding statements so that their position indicates the levels of nesting.

For IF-THEN/ELSE conditionals, DO groups can be used as units for either THEN or ELSE clauses so that you can perform many statements as part of the conditional action. An example follows:

   if x<y then
      do;
         z1=abs(x+y);
         z2=abs(x-y);
      end;
   else
      do;
         z1=abs(x-y);
         z2=abs(x+y);
      end;


Iterative Execution

Chapter Contents
Chapter Contents
Previous
Previous
Next
Next
Top
Top

Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.