SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Search||next

Creating Multiple Observations from a Single Record
Lesson Overview


Introduction

Sometimes you may have raw data files that contain data for several observations in one record. Data is stored in this manner to reduce the size of the entire data file.

Each record can contain

  • repeating blocks of data that represent separate observations

1---+----10---+----20---+----30--
01APR90 68 02APR90 67 03APR90 70
04APR90 74 05APR90 72 06APR90 73
07APR90 71 08APR90 75 09APR90 76


  • an ID field followed by an equal number of repeating fields that represent separate observations

1---+----10---+----20---+----30--
001 WALKING AEROBICS CYCLING
002 SWIMMING CYCLING SKIING
003 TENNIS SWIMMING AEROBICS


  • an ID field followed by a varying number of repeating fields that represent separate observations.

1---+----10---+----20---+----30--
001 WALKING
002 SWIMMING CYCLING SKIING
003 TENNIS SWIMMING


This lesson shows you several ways of creating multiple observations from a single record. This lesson contains 34 pages and takes approximately 45-60 minutes to complete.


Objectives

In this lesson, you learn how to

  • create multiple observations from a single record that contains repeating blocks of data
  • create multiple observations from a single record that contains one ID field followed by the same number of repeating fields
  • create multiple observations from a single record that contains one ID field followed by a varying number of repeating fields.

Additionally, you learn to

  • hold the current record across iterations of the DATA step
  • hold the current record for the next INPUT statement
  • execute SAS statements based on a variable's value
  • explicitly write an observation to a data set
  • execute SAS statements while a condition is true.


Prerequisites

Before taking this lesson, you should have completed the following lessons

Introduction to SAS Programming

Creating SAS Data Sets

Reading Various Types of Raw Data

||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement