Previous Page | Next Page

SAS Component Language Dictionary

COMPAREARRAY



Allows you to compare two arrays for size and data equality
Category: Array

Syntax
Details
Example
See Also

Syntax

rc=COMPAREARRAY(array1,array2);

rc

indicates whether the two arrays match.

0

arrays match

1

arrays do not match

Type: Numeric

array1

is one of the two arrays to be compared.

Type: Array

array2

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:


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

COPYARRAY

DELARRAY

MAKEARRAY

SCL Arrays

Previous Page | Next Page | Top of Page