SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Search||next

Merging SAS Data Sets
Lesson Overview


Introduction

In SAS programming, a common task is to combine observations from two or more data sets into a single observation in a new data set according to the values of a common variable. In DATA step terminology, this is called match-merging.


match-merged data sets

In match-merging, often one data set contains unique values for the common variable (YEAR, Table 1 above), and other data sets contain multiple values for the common variable (YEAR, Table 2 above).

This lesson shows you how to match-merge any number of SAS data sets using the DATA step. When you use the DATA step to perform a match-merge, you have a high degree of control in creating and manipulating data sets.

This lesson contains 44 pages and takes approximately 60-90 minutes to complete.

Note: You can also use PROC SQL to join data sets according to the values of a common variable. For more information, see the lesson Performing Queries Using SQL.


Objectives

In this lesson, you learn to

  • identify default output from match-merging
  • prepare data for match-merging by sorting, if necessary
  • specify data sets to merge and the data set to be created
  • specify the common variable to use in matching observations
  • rename any like-named variables to avoid overwriting values
  • select only matched observations, if desired
  • select variables
  • predict the results of match-merging.


Prerequisites

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

Introduction to SAS Programming

Creating SAS Data Sets

||next


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

Terms of Use & Legal Information | Privacy Statement