Processing a DATA Step That Creates One Observation per Header Record

During the compile phase, the variable type is flagged so that later it can be dropped. The value for Address and Total (SUM statement) are retained.
Compile Phase
As the execution begins, _N_ is 1 and last is 0. Total is 0 because of the sum statement.
Execution Phase
Now the value for type is read, the condition type='H' is true, and therefore the statements in the DO group execute.
Execution Phase
The condition ...

Get SAS Certification Prep Guide: Base Programming for SAS 9, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.