Chapter 22
Using DATA Step Component
Objects
Introduction to DATA Step Component Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
Using the Hash Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
Why Use the Hash Object? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 518
Declaring and Instantiating a Hash Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
Initializing Hash Object Data Using a Constructor . . . . . . . . . . . . . . . . . . . . . . . . 519
Defining Keys and Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 520
Non-Unique Key and Data Pairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521
Storing and Retrieving Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 522
Maintaining Key Summaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
Replacing and Removing Data in the Hash Object . . . . . . . . . . . . . . . . . . . . . . . . 527
Saving Hash Object Data in a Data Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
Comparing Hash Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Using Hash Object Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Using the Hash Iterator Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
About the Hash Iterator Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 531
Declaring and Instantiating a Hash Iterator Object . . . . . . . . . . . . . . . . . . . . . . . . 531
Example: Retrieving Hash Object Data By Using the Hash Iterator . . . . . . . . . . . 532
Using the Java Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
About the Java Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
CLASSPATH and Java Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534
Restrictions and Requirements for Using the Java Object . . . . . . . . . . . . . . . . . . . 536
Declaring and Instantiating a Java Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536
Accessing Object Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536
Accessing Object Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
Type Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 537
Java Objects and Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 539
Passing Java Object Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 540
Java Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
Java Standard Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Java Object Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Introduction to DATA Step Component Objects
SAS provides these five predefined component objects for use in a DATA step:
517
..................Content has been hidden....................

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