SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Hierarchical Files
Creating One Observation per Header Record


Simple DO Groups

You can use a simple DO group with an IF-THEN statement to execute multiple SAS statements based on the value of a variable.


General form, simple DO Group:
DO;
       . . . more SAS statements . . .;
END;

where

  • DO is the keyword that indicates a group of statements are to be executed as a unit until a matching END statement is encountered
  • more SAS statements are any valid statements.


Typically, simple DO groups are used with IF-THEN statements to execute multiple statements depending on whether a condition is true or false.

For example, the expression type='X' defines a condition. When the condition is true, the statements following the keyword DO are executed until the END statement is encountered.

     if type='X' then do;
        input @3 Amount comma6.;
        Total+amount;
     end;

When the condition type='X' is not true, the statements are not executed.


back||next


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

Terms of Use & Legal Information | Privacy Statement