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.
As the execution begins, _N_ is 1 and last is 0. Total is 0 because of the sum statement.
Now the value for type is read, the condition type='H' is true, and therefore the statements in the DO group execute.
The condition ...