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

Hi,

 

I used one dataset as a hash, with "ID" as its key. I also have other variables in the hash that I want to keep and I included them in defineData. 

 

I'd like to output variables in the hash, where the "ID" can not be found in the main dataset, because I'm more interested in variables that dont exist in the main dataset.

 

The codes I'm using now are like this: if hash.find()^=o then output .... But it seems like it outputs variables in the main datasets instead of in the hash.

 

I can't do it by reversing the hash and main dataset, because the main dataset is far larger than my hash. What code should I use to solve it? Any help will be appreciated! 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Remove it from Hash when you find it , and at the end of data step output Hash.

 

data _null_;
 set main end=last;
 ...........
 if hash.check()=o then hash.remove();
 if last then hash.output(dataset:'want');
 run;

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

In similar situation I prefer the SQL.

Let datasets be: SMALL (instead hash) and BIG with ID common in both, then

 

proc sql;

      create table WANT as select * from BIG

      where ID not in (select ID from SMALL);

quit;

airchang
Calcite | Level 5

The dataset is really large (more than 400 GB), so I was suggested to use Hash. But thanks for your help!

Ksharp
Super User

Remove it from Hash when you find it , and at the end of data step output Hash.

 

data _null_;
 set main end=last;
 ...........
 if hash.check()=o then hash.remove();
 if last then hash.output(dataset:'want');
 run;
airchang
Calcite | Level 5
This works! Thanks!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1336 views
  • 0 likes
  • 3 in conversation