SCL Arrays |
Dynamic arrays can be created and initialized in five ways:
with the COPYARRAY function. See Using The COPYARRAY Function for more information.
using simple assignment statements that copy the values of one array into another array. For more information, see Using Assignment Statements.
by a method that returns an array. See Returning Arrays from Methods in SCL Programs for more information.
with the REDIM function. See Resizing Dynamic Arrays in SCL Programs for more information.
with the MAKEARRAY function.
After you have declared a dynamic array, you can create the array with the MAKEARRAY function. The MAKEARRAY function creates an array of the given size with all elements in the array initialized to missing for numerics or blank for characters. The number of dimensions must be the same as what was specified in the DECLARE statement. The low bound for all dynamic arrays is 1, and the high bound is determined at runtime by the values that you specify with the MAKEARRAY (or REDIM) function. For example, the following statements create a one-dimensional dynamic array named STUDENTS that has three elements and initializes these array elements to Mary, Johnny, and Bobby:
Dynamic STUDENTS Array declare char students[*]; students = MAKEARRAY(3); students[1] = 'Mary'; students[2] = 'Johnny'; students[3] = 'Bobby'; put students;
The low bound for STUDENTS is 1, and the high bound 3. The output for this example is
students[1] = 'Mary' students[2] = 'Johnny' students[3] = 'Bobby'
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.