SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Hierarchical Files
Creating One Observation per Header Record


In the previous example, you learned how to create one observation per detail record. But suppose you only want to know how many people reside at each address. You can create a data set that reads each detail record, counts the number of people, and stores this value in a summary variable.

In the example below, this summary variable, Total, is combined with the header record to form an observation in the data set. As you can see, creating one observation per header record condenses a large amount of information into a concise data set.


Raw Data File
1---+----10---+----20
H 321 S. MAIN ST 
P MARY E    21 F
P WILLIAM M 23 M 
P SUSAN K    3 F
H 324 S. MAIN ST 
P THOMAS H  79 M
P WALTER S  46 M
P ALICE A   42 F 
P MARYANN A 20 F 
P JOHN S    16 M 
H 325A S. MAIN ST
P JAMES L 34 M 
P LIZA A 31 F 
H 325B S. MAIN ST
P MARGO K 27 F 
P WILLIAM R 27 M 
P ROBERT W 1 M 
SAS Data Set
Address Total
321 S. MAIN ST     3
324 S. MAIN ST     5
325A S. MAIN ST     2
325B S. MAIN ST     3



back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement