This program illustrates how to read a hierarchical file and combine all levels of information on a single record. Examples of hierarchical files are census data with housing and person records or fertility data with mother and pregnancy records.
For some purposes, users may find the PSC data utility,extract, a more efficient way to rectangularize data, particularly census and CPS files. For information on this option see the documentation for extract.
***************************************************************************
filename pums90 pipe
'zcat /usr/data/public/us/government/pums/1990/1-1000/1990.Z';
filename out1 '1990m.dat';
/* INPUT data */
data a;
retain state msapmsa;
infile pums90;
input @1 type $1. @;
if type='H' then do;
input state $11-12 msapmsa $20-23;
return;
end;
else do;
input sex 11 race 12-14 age 15-16 marital 17 pwgt1 18-21
rpob 29-30 yearsch 51-52 rlabor 91 rearning 127-132;
if (race ne 2) or age "<" 25 or age ">" 64 or sex=1 then delete;
else do;
file out1;
put state $1-2 msapmsa $4-7 age 9-10 marital 12
pwgt1 14-17 rpob 19-20 yearsch 22-23 rlabor 25 rearning 27-32
rage 34 rmarital 36 rrpob 38 ryearsch 40 rrlabor 42;
output;
end;
end;
run;
***************************************************************************
Additional Notes
In a hierarchical file there can be any number of lower level records following the higher level record.
The following is an example of a census file. The record type (housing (H) or person (P)) is in the first column. A household ID is in the next three columns:
H001040506 P424345299992343 P535098321395832 P341132209212245 H002000394 P334902145394456 H003309387 H004233245 P224879062312789 P334293876109824 P344218970098678 P334123449900723
The number of persons in each household is as follows:
Household ID Household Size 001 3 002 1 003 empty (0) 004 4
Recent resources, events, news
Knodel et al. "Gendered Housework in Vietnam." PSC Research Report.
Couper. Designing Effective Web Surveys
Monday, Oct 13
Jamie Jones
"Fertility & Risk Aversion on Utah Frontier"
W A R N I N G
If you are reading this, it may be that you are using rather old web browsing software that does not support modern international Web technology standards. For a better experience of the Web and this site in particular, please upgrade your web browser software today. The following are good choices: Firefox 2; Opera 9; Safari 3.