Chapter 24
Using DATA Step Component
Objects
Introduction to DATA Step Component Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 527
Using the Hash Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
Why Use the Hash Object? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
Declaring and Instantiating a Hash Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529
Initializing Hash Object Data Using a Constructor . . . . . . . . . . . . . . . . . . . . . . . . 529
Defining Keys and Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Non-Unique Key and Data Pairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
Storing and Retrieving Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 532
Maintaining Key Summaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Replacing and Removing Data in the Hash Object . . . . . . . . . . . . . . . . . . . . . . . . 537
Saving Hash Object Data in a Data Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 538
Comparing Hash Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
Using Hash Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
Using the Hash Iterator Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
About the Hash Iterator Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 541
Declaring and Instantiating a Hash Iterator Object . . . . . . . . . . . . . . . . . . . . . . . . 541
Example: Retrieving Hash Object Data By Using the Hash Iterator . . . . . . . . . . . 542
Using the Java Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
About the Java Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
CLASSPATH and Java Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
Restrictions and Requirements for Using the Java Object . . . . . . . . . . . . . . . . . . . 546
Declaring and Instantiating a Java Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
Accessing Object Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
Accessing Object Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Type Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Java Objects and Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549
Passing Java Object Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550
Java Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
Java Standard Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
Java Object Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553
Introduction to DATA Step Component Objects
SAS provides these five predefined component objects for use in a DATA step:
527

Get SAS 9.4 Language Reference, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.