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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.