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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 970 views
  • 0 likes
  • 3 in conversation