Chapter Contents |
Previous |
Next |
SAS Component Language: Reference |
Dynamic arrays can be created and initialized in five ways:
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 ArrayThe low bound for STUDENTS is 1, and the high bound 3. The output for this example is
declare char students[*]; students = MAKEARRAY(3); students[1] = 'Mary'; students[2] = 'Johnny'; students[3] = 'Bobby'; put students;
students[1] = 'Mary' students[2] = 'Johnny' students[3] = 'Bobby'
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.