SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating Variables
Executing Multiple Statements Conditionally


DO Group Processing

To execute a group of SAS statements as a unit, you can use a DO group.


General form, DO group:
DO;
      statement(s);
END;

where

  • DO designates a group of statements to be executed as a unit until a matching END statement is encountered.

  • statement(s) is any valid SAS statement, including IF-THEN and ELSE statements. You can process any number of executable SAS statements in a DO group.

  • END ends the DO group.


You can now revise your DATA step to process these statements in a DO group rather than two conditional statements.
     data finance.newloan;
        set finance.records(drop=amount rate);
        length Type $ 14;
        TotalLoan+payment;
        if code='1' then
           do;
               if months=360 then
                  type='Fixed Mortgage';
               else type='Fixed Other';
           end;
        else type='Variable';
     run;

Let's look at the execution of this DATA step line by line to see how the DO group executes.


back||next


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

Terms of Use & Legal Information | Privacy Statement