SAS Component Language Dictionary |
Category: | Array |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
rc=COMPAREARRAY(array1,array2); |
indicates whether the two arrays match.
0 |
arrays match |
1 |
arrays do not match |
Type: Numeric
is one of the two arrays to be compared.
Type: Array
is one of the two arrays to be compared.
Type: Array
Details |
The COMPAREARRAY function allows you to compare two arrays for size and data equality. To be considered equal, the arrays must:
have the same number of dimensions
be of the same type
have the same bounds
have the same values in each element.
Example |
This example compares several different arrays.
DCL num n1(5) n2(5,5) n3(*) n4(5) n5(*,*); DCL char c1(5); DCL num rc; rc = comparearray(n1,n2); put rc=; rc = comparearray(n1,c1); put rc=; rc = comparearray(n1,n3); put rc=; n3 = makearray(3); rc = comparearray(n1,n3); put rc=; rc = redim(n3,5); rc = comparearray(n1,n3); put rc=; do i=1 to 5; n1[i] = i; n4[i] = i; end; rc = comparearray(n1,n4); put rc=; rc = copyarray(n2,n5); rc = comparearray(n2,n5); put rc=; rc = delarray (n3); rc = delarray (n5);
The output for this code would be:
rc=1 rc=1 rc=1 rc=1 rc=0 rc=0 rc=0
See Also |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.