Introduction

In SAS programming, a common task is to combine observations from two or more data sets into a new data set. Using the DATA step, you can combine data sets in several ways, including the following:



Method of Combining Illustration
One-to-one reading

Creates observations that contain all of the variables from each contributing data set.

Combines observations based on their relative position in each data set.

Statement: SET

One-to-one reading
Concatenating

Appends the observations from one data set to another.

Statement: SET

Concatenating
Interleaving

Intersperses observations from two or more data sets, based on one or more common variables.

Statements: SET, BY

Interleaving
Match-merging

Matches observations from two or more data sets into a single observation in a new data set according to the values of a common variable.

Statements: MERGE, BY

Match-merging


Note: You can also use PROC SQL to join data sets according to common values. PROC SQL enables you to perform many other types of data set joins. See the SQL Processing with SAS e-learning course for additional training.


This lesson shows you how to combine SAS data sets using one-to-one reading, concatenating, interleaving, and match-merging. When you use the DATA step to combine data sets, you have a high degree of control in creating and manipulating data sets.



2 hours



In this lesson, you learn to

  • perform one-to-one reading of data sets
  • concatenate data sets
  • interleave data sets
  • match-merge data sets
  • rename any like-named variables to avoid overwriting values
  • select only matched observations, if desired
  • predict the results of match-merging.

complete the following lessons:

  • .