DATA Step, Macro, Functions and more

Define key and define data in hashing

Super Contributor
Posts: 625

Define key and define data in hashing

I've trouble understanding the defining keys and data in hashing. I read the document under


Still I couldn't understand. May I request someone to explain about defining keys and data in hashing in simple terms?


Thanks in advance for any help you offer me.

Super User
Posts: 23,773

Re: Define key and define data in hashing

Valued Guide
Posts: 864

Re: Define key and define data in hashing

I am going through some training myself so there are most likely better sources but I will explain something as I understand it to join the conversation:


data want;
merge emphours (in=a)
by empid;
if a;

data empinfo;
length empid $6. empln $30. empfn $25. empmi $1. gender $1. startdate 8. emppaylevel $5.;
if _N_ = 1 then do;
    declare hash new(dataset: 'employees',ordered: 'y');
call missing(empln,empfn,empmi,gender,startdate,emppaylevel);
set emphours;
rc = new.find();
drop rc;
format startdate mmddyy10.;


The two pieces of code produce the same results, definekey is the key in the hash table that I am generating and the field that I will be joining on.  definedata() is the fields that I want to pull in.  This is a simple merge, I am pulling fields from the employee dataset, joining to the emphours dataset.  This is a very simple example for hash.


Hope I provided some help.



Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation