Chapter 21
Reading, Combining, and
Modifying SAS Data Sets
Definitions for Reading, Combining, and Modifying SAS Data Sets . . . . . . . . . . . 465
Overview of Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Reading SAS Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Reading a Single SAS Data Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Reading from Multiple SAS Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Controlling the Reading and Writing of Variables and Observations . . . . . . . . . . 467
Combining SAS Data Sets: Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
What You Need to Know Before Combining Information
Stored in Multiple SAS Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
The Four Ways That Data Can Be Related . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
Access Methods: Sequential versus Direct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
Overview of Methods for Combining SAS Data Sets . . . . . . . . . . . . . . . . . . . . . . 471
Overview of Tools for Combining SAS Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . 474
How to Prepare Your Data Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 476
Combining SAS Data Sets: Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Concatenating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 478
Interleaving . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
One-to-One Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
One-to-One Merging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 489
Match-Merging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
Updating with the UPDATE and the MODIFY Statements . . . . . . . . . . . . . . . . . . 497
Error Checking When Using Indexes to Randomly Access or Update Data . . . . 507
The Importance of Error Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507
Error-Checking Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508
Example 1: Routing Execution When an Unexpected Condition Occurs . . . . . . . 509
Example 2: Using Error Checking on All Statements That Use KEY= . . . . . . . . . 511
Definitions for Reading, Combining, and
Modifying SAS Data Sets
In the context of DATA step processing, the terms reading, combining and modifying
have these meanings:
465
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.250.11