Previous Page | Next Page

SAS Component Language Dictionary

REDIMOPT



Marks an array as implicitly growable
Category: Array

Syntax
Details
Example
See Also

Syntax

rc=REDIMOPT(array);

rc

indicates whether the operation was successful.

0

successful

[ne]0

not successful

Type: Numeric

array

is the dynamic array that you want to be implicitly growable.

Type: Array


Details

When an array is implicitly growable, you can set the value for an out-of-bounds element without first using the REDIM function to enlarge the array.

For each out-of-bounds assignment, if the index value of the new element is greater than twice the current high bound of the corresponding dimension, then that dimension increases to the index value of the new element. If the index value of the new element is less than twice the current high bound of the corresponding dimension, then the corresponding dimension grows to twice its current size.

You must still allocate the array before you can mark it as implicitly growable.


Example

The following example defines two dynamic arrays, a numeric array named ARR and a character array named CARR. The code marks both arrays as implicitly growable and assigns values to out-of-bounds elements.

init:
dcl num arr[*];
arr = makearray(3);
rc = redimopt(arr);

if rc then return;

/* The array size will double to 6. */
arr[5] = 5;
/* The array will grow to 13 because the subscript */
/* is greater than 2*6.                            */
arr[13] = sum(4,7);

put arr=;

/* Character arrays are also implicitly growable. */
dcl char carr[*];
rc = redimopt(carr);
if rc then return;
carr = makearray(5);
/* The array will grow to 10. */
do i=1 to 7;
   carr[i] = 'test' || i;
end;
put carr=;
return;


See Also

MAKEARRAY

REDIM

SCL Arrays

Previous Page | Next Page | Top of Page