SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Hierarchical Files
Creating One Observation per Header Record


As you write the DATA step to read this file, you need to think about performing several tasks. First, the value of Address must be retained as detail records are read and summarized.



     data perm.people;
        infile census;
        retain Address;
1---+----10---+----
321 S. MAIN ST 
P MARY E    21 F
P WILLIAM M 23 M 
P SUSAN K    3 F


Next, the value of type must be read to determine if the current record is a header or a detail record. Add an @ to hold the record for another INPUT statement to read the remaining values.



     data perm.people;
        infile census;
        retain Address;
        input type $1. @;
V---+----10---+----
H 321 S. MAIN ST 
P MARY E    21 F
P WILLIAM M 23 M 
P SUSAN K    3 F


When the value of type indicates a header record, several statements need to be executed. When the value of type indicates a detail record, you need to define an alternative set of actions. Let's take a look at executing different sets of statements for each value of type.



back||next


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

Terms of Use & Legal Information | Privacy Statement