Reading Hierarchical Files |
Creating One Observation per Detail
Record |
Reading a Detail Record
Now think about what needs to happen when a detail record
is read. Remember, you want to write an observation to the data set only
when the value of |
V---+----10---+----
H 321 S. MAIN ST
P MARY E 21 F
P WILLIAM M 23 M
P SUSAN K 3 F
You can use a
subsetting IF statement to check for the
condition that type is P. The remaining DATA step
statements execute only when the condition is true. If type
is not P, then the values for Name , Age ,
and Gender are not read, the values in the program data vector
are not written to the data set as an observation, and control returns to
the top of the DATA step.
The values for data perm.people; infile census; retain Address; input type $1. @; if type='H' then input @3 Address $15.; if type='P'; input @3 Name $10. @13 Age 3. @15 Gender $1.; run; |
Dropping Variables
Because data perm.people (drop=type); infile census; retain Address; input type $1. @; if type='H' then input @3 Address $15.; if type='P'; input @3 Name $10. @13 Age 3. @15 Gender $1.; run; |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.