Date: Thu, 26 Jan 2006 22:44:29 -0500
Reply-To: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Subject: Re: Hash Comparing Key
SUBSCRIBE SAS-L Peter Yeltzin wrote:
> Is there anyway i can just compare the key of a hash with a column
> from a data set to find non-matches? What i want to do is find from
> two data sets if there are any different records in a particular
> column and save it to a dataset.
> If i cant do this ive tried so far:
> data match;
> length name $20;
> length label $30;
> if _N_=1 then do;
> declare hash hh(dataset: "work.small");
> rc = hh.defineKey('label');
> rc = hh.defineData('name');
> call missing(label, name);
> rc = hh.defineDone();
> set big;
> rc = hh.find();
> if (rc=1) then output;
> But it returns an empty record set when there should be records.
if (rc ne 0)
find() returns zero when succesful and non-zero when not succesful. The
non-zero is definitely not 1.
> This isnt the best solution as i only really want to compare the name
> but the label and the name definition is a bit of a fudge that should
> also work.
Fudging doesn't work with hashing.
If the lookup key is variable 'label' then the input data in set big had
better have a column 'label'
If you only want to test for a key match, then you _do_not_need_ defineData.
Just skip it altogether. You only need to defineData if the find has to
pull in satellite data required for additional processing.
Richard A. DeVenezia