BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sassharp
Calcite | Level 5

In hash join for testing purposes I do need to use for only one record out of dataset. I mean how the look up process or join would be by using one ID. For eaxmplae in proc sql left join

proc sql;

create table test as

select *

from table1

left join

table2

where table1.id=4 and table1.id=table2.id;

run;


1 ACCEPTED SOLUTION

Accepted Solutions
sassharp
Calcite | Level 5

data match_on_movie_titles(drop=rc);

if 0 then set sasuser.flightschedule sasuser.flightattendants; /* load variable properties into hash tables */

if _n_ = 1 then do;

declare Hash MatchTitles (dataset: "sasuser.flightattendants"); /* declare the name MatchTitles

for hash */

MatchTitles.DefineKey ("EmpID"); /* identify variable to use as key */

MatchTitles.DefineData (

"EmpID","JobCode","LastName","FirstName"); /* identify columns of data */

MatchTitles.DefineDone (); /* complete hash table definition */

end;

set sasuser.flightschedule(where=(EmpID='1113'));

if MatchTitles.find(key:EmpID)=0 then output; /* lookup TITLE in MOVIES table

using MatchTitles hash */

run;

View solution in original post

3 REPLIES 3
Haikuo
Onyx | Level 15

Hi, if I understand you correctly:

blah blah blah

yourhash.definekey('id');

blah blah blah

rc=yourhash.find(key:4);

blah blah blah

Regards,

Haikuo

sassharp
Calcite | Level 5

@HaiKuo

would you change this code for any one EMPID?

you can find the data sets in your sasuser library.

data match_on_movie_titles(drop=rc);

if 0 then set sasuser.flightschedule sasuser.flightattendants; /* load variable properties into hash tables */

if _n_ = 1 then do;

declare Hash MatchTitles (dataset:"sasuser.flightattendants"); /* declare the name MatchTitles

for hash */

MatchTitles.DefineKey ("EmpID"); /* identify variable to use as key */

MatchTitles.DefineData (

"EmpID","JobCode","LastName","FirstName"); /* identify columns of data */

MatchTitles.DefineDone (); /* complete hash table definition */

end;

set sasuser.flightschedule;

if MatchTitles.find(key:EMPID) = 0 then output; /* lookup TITLE in MOVIES table

using MatchTitles hash */

run;

sassharp
Calcite | Level 5

data match_on_movie_titles(drop=rc);

if 0 then set sasuser.flightschedule sasuser.flightattendants; /* load variable properties into hash tables */

if _n_ = 1 then do;

declare Hash MatchTitles (dataset: "sasuser.flightattendants"); /* declare the name MatchTitles

for hash */

MatchTitles.DefineKey ("EmpID"); /* identify variable to use as key */

MatchTitles.DefineData (

"EmpID","JobCode","LastName","FirstName"); /* identify columns of data */

MatchTitles.DefineDone (); /* complete hash table definition */

end;

set sasuser.flightschedule(where=(EmpID='1113'));

if MatchTitles.find(key:EmpID)=0 then output; /* lookup TITLE in MOVIES table

using MatchTitles hash */

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1000 views
  • 0 likes
  • 2 in conversation