How SAS Processes Programs

When you submit a DATA step, SAS processes the DATA step and creates a new SAS data set. A SAS DATA step is processed in two phases:
Figure 7.1 DATA Step Process
SAS process the DATA step in two phases: compilation and execution phase.
When you submit a DATA step for execution, SAS checks the syntax of the SAS statements and compiles them. In this phase, SAS identifies the type and length of each new variable, and determines whether a variable type conversion is necessary for each subsequent reference to a variable. During the compilation phase, SAS creates the following items:
  • program data vector (PDV)
  • descriptor information
When the compilation phase is complete, the descriptor portion of the new data set is created.
By default, a simple DATA step iterates once for each observation that is being created. The flow of action in the execution phase of a simple DATA step is described as follows:
  1. The DATA step begins with a DATA statement. Each time the DATA statement executes, a new iteration of the DATA step begins, and the _N_ automatic variable is incremented by 1. The _N_ automatic variable represents the number of times the DATA step has iterated.
  2. SAS sets the newly created program variables to missing in the program data vector (PDV).
  3. SAS reads an observation from a SAS data set directly into the PDV. You can use MERGE, SET, MODIFY, or UPDATE statement to read a record.
  4. SAS executes any subsequent programming statements sequentially and updates the PDV.
  5. When SAS executes the last statement in the DATA step, all values (except temporary variables and those marked to be dropped) are written as a single observation to the data set. Note that variables that you read with a SET, MERGE, MODIFY, or UPDATE statement are not reset to missing here.
  6. SAS counts another iteration, reads the next observation, and executes the subsequent programming statements for the current observation.
  7. The DATA step terminates when SAS encounters the end-of-file in a SAS data set.
Compilation and Execution Phases of DATA Step Processing shows the general flow of DATA step processing for reading raw data.
Figure 7.2 Compilation and Execution Phases of DATA Step Processing
Compilation and Execution Phases of DATA Step Processing
Last updated: August 23, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.80.236