Chapter Contents |
Previous |
Next |
REDIM |
Category: | Array |
Syntax | |
Details | |
Examples | |
Example 1: Create an Array and Resize It Preserving the Data | |
Example 2: Create an Array and Resize it Without Preserving the Data | |
See Also |
Syntax |
rc=REDIM(array,dim1<,dim2<,dim3....<,dimN>...>>); |
0 | successful |
0 | not successful |
Type: Numeric
Type: Array
Type: Numeric
Details |
You can use the REDIM function to resize a dynamic array. You cannot change the numbers of dimensions or type of the array, only the bounds. The REDIM function will preserve the data in the array. However, if you resize the array to a smaller size, you will lose the data in the eliminated elements. There is no limit to the number of times that you can resize an array.
Examples |
The example creates a one-dimensional array of 5 elements and resizes it, preserving the data, to 10 elements.
DCL num a(*); rc = makearray(a,3); do i=1 to dim(a); a[i]=i; end; rc = redim(a,5); put a=; rc=delarray(a);
The output would be:
a= a[1]=1 a[2]=2 a[3]=3 a[4]=. a[5]=.
The example creates a two-dimensional 5x5 array, resizes it to a 10x10 array and does not preserve the data.
DCL num a(*); rc = makearray(a,3); do i=1 to dim(a); a[i]=i; end; rc = makearray(a,5); put a=; rc = delarray(a);
The output would be:
a= a[1]=. a[2]=. a[3]=. a[4]=. a[5]=.
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.