Reading Hierarchical Files |
Lesson
Overview |
Introduction
Raw data files can be hierarchical in structure, consisting of a header record and one or more detail records. Typically, each record contains a field that identifies the record type. Here, the P indicates a header record that contains a patient's ID number. The C indicates a detail record that contains the date of the patient's appointment and the charges incurred. |
Raw Data File
1---+----10---+----20
P 1095 $45.0
C 01-08-89 $37.5
C 01-17-89 $156.5
P 1096 $109.0
C 01-09-89 $45.0
P 1097 $45.0
C 01-02-89 $37.0
P 1099 $45.0
C 01-03-89
C 01-05-89
P 1201
C 01-05-89
C 01-10-89
You can build a SAS data set from a hierarchical file by creating one observation per detail record and storing each header record as part of the observation. |
SAS Data Set
Obs
ID
Date
Amount
1
1095
01/08/89
$45.00
2
1095
01/17/89
$37.50
3
1096
01/09/89
$156.50
4
1097
01/02/89
$109.00
5
1099
01/03/89
$45.00
6
1099
01/05/89
$45.00
7
1201
01/05/89
$37.00
8
1201
01/10/89
$45.00
You can also build a SAS data set from a hierarchical file by creating one observation per header record and combining the information from detail records into summary variables. |
SAS Data Set
Obs
ID
Total
1
1095
$82.50
2
1096
$156.50
3
1097
$109.00
4
1099
$90.00
5
1201
$82.00
In this lesson, you learn how to read from a hierarchical file and create
a SAS data set that contains one observation for each detail record or one
observation for each header record.
This lesson contains 31 pages and takes approximately 45-60 minutes to complete. |
Objectives
In this lesson, you learn how to
You can also review how to
Before taking this lesson, you should have completed the following lessons: Introduction to SAS Programming |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.