Reading Hierarchical Files |
Creating One Observation per Detail
Record |
Retaining Variable Values
As you write the DATA step to read this file, remember that you want to
keep the header record as a part of each observation until
the next header record is encountered. To do this, you need to use a RETAIN
statement to retain the values for |
General form, RETAIN statement:
where variable(s) names a variable whose value is retained across iterations of the DATA step. You can specify more than one variable in a RETAIN statement.
If you do not specify a variable in the RETAIN statement, then the values of all the variables in the data set are retained. RETAIN; |
When a RETAIN statement specifies variables, new variables are created. Therefore, you must name any variables used in a RETAIN statement exactly as you want them stored in the data set. |
data perm.people; infile census; retain Address; |
|
Next, you need to read the first field in each record, which identifies the record's type. You also need to use the @ line-hold specifier to hold the current record so that the other values in the record can be read. |
data perm.people; infile census; retain Address; input type $1. @; |
|
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.