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 a DO group or a module.

DO groups have two principal uses:

DO groups have the following general form:

DO ;
    additional statements
END ;

As with IF-THEN/ELSE statements, with DO groups any number of nesting levels is allowed. 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 here, 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;
 

Previous Page | Next Page | Top of Page