SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Debugging and Testing DATA Steps
Understanding DATA Step Processing


When the SET statement is compiled, a slot is added to the program data vector for each variable in the input data set. The input data set supplies the variable names and attributes such as type and length.

     data finance.duejan;
        set finance.loans;
        Interest=amount*(rate/12);
     run;

SAS Data Set Finance.Loans
Account Amount Rate Months Payment
101-1092 22000 0.1000 60 467.43
101-1731 114000 0.0950 360 958.57
101-1289 10000 0.1050 36 325.02
101-3144 3500 0.1050 12 308.52


Program Data Vector with automatic variables

Any variables created in the DATA step are also added to the program data vector. For example, the assignment statement below creates the variable Interest. As the statement is compiled, the variable is added to the program data vector. The attributes of Interest are determined by the expression in the statement. Because the expression produces a numeric value, Interest is defined as a numeric variable and assigned a default length of 8.

     data finance.duejan;
        set finance.loans;
        Interest=amount*(rate/12);
     run;

Programmed variables added to PDV

At the bottom of the DATA step (in this example, when the RUN statement is encountered), the compilation phase is complete and the descriptor portion of the new SAS data set is created. The descriptor portion of the data set includes:

  • name of the data set
  • number of observations and variables
  • names and attributes of the variables.

Description of Finance.Duejan
Observations: 0
Variables: 6
Variable Type Length
Account CHAR 8
Amount NUM 8
Rate NUM 8
Months NUM 8
Payment NUM 8
Interest NUM 8


At this point, the data set contains the six variables defined in the input data set and assignment statement. Remember, _N_ and _ERROR_ are not written to the data set. There are no observations because the DATA step has not yet executed.


back||next


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

Terms of Use & Legal Information | Privacy Statement