Lesson 15: Combining SAS Data Sets -- Part I

Printer-friendly versionPrinter-friendly version

Introduction

In this lesson, we will learn how to combine data sets in four different ways — one-to-one reading, one-to-one merging, concatenating and interleaving. Although one-to-one reading and one-to-one merging both involve placing one data set to "to the right" of other data sets to create a single "fat" data set, the results can differ slightly. Concatenating involves stacking one data set "below" other data sets to create a single "tall" data set. Interleaving also involves stacking data sets, but it only deals with sorted data sets. That is, interleaving combines individual sorted data sets into one big sorted data set. Once we've learned the four mentioned ways of combining SAS data sets, we'll also learn how to use DATA step options at the same time that we one-to-one read, one-to-one merge, concatenate or interleave two or more SAS data sets.

Learning objectives & outcomes

Upon completing this lesson, you should be able to do the following:

  • write SAS code to one-to-one read two or more SAS data sets
  • predict the size of the output data set when one-to-one reading two or more SAS data sets
  • write SAS code to one-to-one merge two or more SAS data sets
  • predict the size of the output data set when one-to-one merging two or more SAS data sets
  • write SAS code to concatenate two or more SAS data sets
  • predict the size of the output data set when concatenating two or more SAS data sets
  • understand how SAS handles concatenating data sets when variable types differ across the input data sets
  • understand how SAS handles concatenating data sets when formats, informats, or labels differ across the input data sets
  • understand how SAS handles concatenating data sets when variables have different lengths across the input data sets
  • write SAS code to interleave two or more SAS data sets
  • predict the size of the output data set when interleaving two or more SAS data sets
  • use the PUT function to perform an explicit numeric-to-character conversion
  • use any of the DATA step options at the same time that you one-to-one read, one-to-one merge, concatenate or interleave two or more SAS data sets

Our "to do" list for this lesson

In order to complete the lesson you should:

  1. Read the lesson pages that follows.
  2. Type up your answers to the homework problems in a Word file named homework15_yourPSUloginid. If your PSU login id is xyz123, then name your file homework15_xyz123. Upload the file to the Lesson #15 Homework Dropbox.
  3. Post any questions or comments you have concerning the lesson's material to the Lesson #15 General Discussion Board.
  4. Take the Lesson #15 Mastery Quiz. Remember two things: i) You have 20 minutes to complete the quiz, and ii) as soon as you hit the "submit" button, your answers are submitted and graded, and the quiz becomes closed to you.