Processing a DATA Step That Creates One Observation per Header Record

  1. During the compilation phase, the variable type is flagged so that later it can be dropped. The value for Address and Total (sum statement) are retained.
    Compilation Phase
  2. As the execution begins, _N_ is 1 and Last is 0. Total is 0 because of the sum statement.
    Execution Phase
  3. The value for Type is read, the condition type='H' is true, and therefore the statements in the DO group execute.
  4. The condition N>1 is not true, so the OUTPUT statement is not executed. However, Total is assigned the value of 0 and the value for Address is read.
    Execution Phase
  5. The END statement closes the DO group. The alternative condition expressed in the ELSE statement is not checked because the first condition, Type='H', was true.
  6. The value of Last is still 0, so the OUTPUT statement is not executed. Control returns to the top of the DATA step.
  7. During the second iteration, the value of type is 'P' and Total is incremented by 1. Again, the value of Last is 0, so control returns to the top of the DATA step.
    Execution Phase
  8. During the fifth iteration, the value of Type is 'H' and _N_ is greater than 1, so the values for Address and Total are written to the data set as the first observation.
  9. As the last record in the file is read, the variable Last is set to 1. Now that the condition for Last is true, the values in the program data vector are written to the data set as the final observation.
    Execution Phase
Last updated: January 10, 2018
..................Content has been hidden....................

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