UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SPSS FAQ
Reading hierarchical data

Q.
My data file has two different kinds of records, family records and person records. How do I read the data so that the family information is included for each person?

A.
Here is an example dataset with two kinds of records: Family records and person records. The data are organized such the the family record comes first and all the person records for that family follow it. The family records are the shorter data lines and the person records are the longer ones.

06470 1 1
32161 232 0
19082 230 1
07470 1 0
11231 240 1
08470 1 0
43711 227 0
09470 1 0
40221 213 1
41162 222 0
16173 224 1
10470 1 1
30111 220 0
36222 211 1
11470 1 0
21751 217 0
33962 210 1
32143 226 1

Here are the codebooks for the family and person records.

family record:                            person record:
column 1-5   family id                    column 1-4  person id
column 7     record type                  column 5    person number
             (1 = family)                 column 7    record type
column 9     group                                    (2= preson)
                                          column 8-9  age
                                          column 11   male

The following syntax example reads and displays in the data from the two different types of records. The file type is nested and the number in column seven indicates which record type the data belong to. There is a separate data list for each record type.

file type nested record=7.
record type 1.
data list / famid 1-5 group 9.
record type 2.
data list / personid 1-4 pernum 5 age 8-9 male 11.
end file type.

begin data
06470 1 1
32161 232 0
19082 230 1
07470 1 0
11231 240 1
08470 1 0
43711 227 0
09470 1 0
40221 213 1
41162 222 0
16173 224 1
10470 1 1
30111 220 0
36222 211 1
11470 1 0
21751 217 0
33962 210 1
32143 226 1
end data.

list.

Here is what the final dataset looks like.

FAMID GROUP PERSONID PERNUM AGE MALE

 6470   1     3216      1    32   0
 6470   1     1908      2    30   1
 7470   0     1123      1    40   1
 8470   0     4371      1    27   0
 9470   0     4022      1    13   1
 9470   0     4116      2    22   0
 9470   0     1617      3    24   1
10470   1     3011      1    20   0
10470   1     3622      2    11   1
11470   0     2175      1    17   0
11470   0     3396      2    10   1
11470   0     3214      3    26   1

Number of cases read:  12    Number of cases listed:  12

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California