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-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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
  • 4 replies
  • 941 views
  • 0 likes
  • 3 in conversation