Chapter 23
Array Processing
Definitions for Array Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
A Conceptual View of Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
One-Dimensional Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
Two-Dimensional Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
Syntax for Defining and Referencing an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
Processing Simple Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558
Grouping Variables in a Simple Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558
Using a DO Loop to Repeat an Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
Using a DO Loop to Process Selected Elements in an Array . . . . . . . . . . . . . . . . . 559
Selecting the Current Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560
Defining the Number of Elements in an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
Rules for Referencing Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
Variations on Basic Array Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562
Determining the Number of Elements in an Array Efficiently . . . . . . . . . . . . . . . . 562
DO WHILE and DO UNTIL Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 562
Using Variable Lists to Define an Array Quickly . . . . . . . . . . . . . . . . . . . . . . . . . . 563
Multidimensional Arrays: Creating and Processing . . . . . . . . . . . . . . . . . . . . . . . . 563
Grouping Variables in a Multidimensional Array . . . . . . . . . . . . . . . . . . . . . . . . . 563
Using Nested DO Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
Specifying Array Bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Identifying Upper and Lower Bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565
Determining Array Bounds: LBOUND and HBOUND Functions . . . . . . . . . . . . 566
When to Use the HBOUND Function Instead of the DIM Function . . . . . . . . . . . 566
Specifying Bounds in a Two-Dimensional Array . . . . . . . . . . . . . . . . . . . . . . . . . . 567
Examples of Array Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
Example 1: Using Character Variables in an Array . . . . . . . . . . . . . . . . . . . . . . . . 567
Example 2: Assigning Initial Values to the Elements of an Array . . . . . . . . . . . . . 568
Example 3: Creating an Array for Temporary Use in the Current DATA Step . . . 569
Example 4: Performing an Action on All Numeric Variables . . . . . . . . . . . . . . . . 570
555
..................Content has been hidden....................

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