11-22-2011 09:22 AM
I am really new to using hash objects. I can do the basics, but I was wondering if someone can lend me a little help. The short version is that I want to compare the key (ID) with two different variables in the hash object (ID and parentID). If ID matches ID in the hash object, I want the program to pull some data into the main data set. I know how to do this portion. However, I also want to compare ID to the variable parentID in the hash object, and if they match, then I want to put a "yes" in a different variable (parent) in the main data set. Is it possible to do this, to compare the key to two different variables in the hash? The code I have so far is below, and it does the first portion of what I want of pulling in information if the key matches.
length ParentID $13;
length ParentName $80;
length ParentNPLStatus $30;
if _n_= 1 then do;
declare hash hh(dataset: 'NPL.parent');
hh.definedata('ParentID', 'ParentName', 'ParentNPLStatus');
if hh.find() ge 0;
11-22-2011 10:34 PM
Welcome to Hash World!.
I bet you will like it more and more.
About your question, I think answer is yes.
You need build another Hash Table to hold parentID as a key, then use check() method to see whether they are matched.
If matched then parent='yes';
The best way to get answer is to post some sample data and output you need.