backnextLearning Path
   


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 that the patient has incurred.


Raw Data File

1---+----10---+----20
P  1095
C  01-08-89  $45.0 
C  01-17-89  $37.5 
P  1096
C  01-09-89  $156.5
P  1097
C  01-02-89  $109.0
P  1099
C  01-03-89  $45.0 
C  01-05-89  $45.0 
P  1201  
C  01-05-89  $37.0  
C  01-10-89  $45.0 


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 either one observation for each detail record or one observation for each header record.


Notice:

Setting Up Filerefs for Practices in This Lesson




Time to Complete

This lesson contains pages and takes approximately 30 minutes to complete.



Objectives

In this lesson, you learn to

  • retain the value of a variable
  • conditionally execute a SAS statement
  • determine when the last observation is being processed
  • conditionally execute multiple SAS statements.

You can also review how to

  • use a line-hold specifier to hold the current record
  • explicitly write an observation to a data set.

Prerequisites

Before taking this lesson, you should complete the following lessons:

  • .

  Copyright © 2003 SAS Institute Inc., Cary, NC, USA. All rights reserved.
Terms of Use & Legal Information | Privacy Statement
backnext