Chapter 6
Starting with SAS Data Sets
Introduction to Starting with SAS Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Understanding the Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Input SAS Data Set for Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Reading Selected Observations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Reading Selected Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Overview of Reading Selected Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Keeping Selected Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Dropping Selected Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Choosing between Data Set Options and Statements . . . . . . . . . . . . . . . . . . . . . . . . 98
Choosing between the DROP= and KEEP= Data Set Option . . . . . . . . . . . . . . . . . 98
Creating More Than One Data Set in a Single DATA Step . . . . . . . . . . . . . . . . . . . 99
Using the DROP= and KEEP= Data Set Options for Efficiency . . . . . . . . . . . . . . 101
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Data Set Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Learning More . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Introduction to Starting with SAS Data Sets
Purpose
In this section, you will learn how to do the following:
• display information about a SAS data set
• create a new SAS data set from an existing SAS data set rather than creating it from
raw data records
Reading a SAS data set in a DATA step is simpler than reading raw data because the
work of describing the data to SAS has already been done.
91