Previous Page | Next Page

Hash and Hash Iterator Object Language Elements

EQUALS Method



Determines whether two hash objects are equal.
Applies to: Hash object

Syntax
Arguments
Details
Examples

Syntax

rc=object.EQUALS(HASH: 'object', RESULT: variable name);


Arguments

rc

specifies whether the method succeeded or failed.

A return code of zero indicates success; a nonzero value indicates failure. If you do not supply a return code variable for the method call and the method fails, then an appropriate error message is written to the log.

object

specifies the name of a hash object.

HASH:'object'

specifies the name of the second hash object that is compared to the first hash object.

RESULT: variable name

specifies the name of a numeric variable name to hold the result. If the hash objects are equal, the result variable is 1. Otherwise, the result variable is zero.


Details

The following example compares H1 to H2 hash objects:

 length eq k 8;
 declare hash h1();
 h1.defineKey('k');
 h1.defineDone();

 declare hash h2();
 h2.defineKey('k');
 h2.defineDone();

 rc = h1.equals(hash: 'h2', result: eq);
 if eq then
   put 'hash objects equal';
 else
   put 'hash objects not equal';

The two hash objects are defined as equal when all of the following conditions occur:


Examples

In the following example, the first return call to EQUALS returns a nonzero value and the second return call returns a zero value.

data x;
 length k eq 8;
 declare hash h1();
 h1.defineKey('k');
 h1.defineDone();

 declare hash h2();
 h2.defineKey('k');
 h2.defineDone();

 k = 99;
 h1.add();
 h2.add();

 rc = h1.equals(hash: 'h2', result: eq);
 put eq=;

 k = 100;
 h2.replace();

 rc = h1.equals(hash: 'h2', result: eq);
 put eq=;

 run;

Previous Page | Next Page | Top of Page