# Lesson 15: Combining SAS Data Sets -- Part I

Printer-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.