BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ChrisNZ
Tourmaline | Level 20
Give it a go.If the hash table is too slow, the where clause should work.SAS slows down dramatically when reading many tables at once but 60 should be alright.
paulrockliffe
Obsidian | Level 7
Thanks for all the help, I've got this all up and running now and it works really well!
I'm using the same approach for something else and wondered if it was simple to add a couple of extra features:

How do I modify the code so that the lookup table is joined on a key that has a different name in each table?

How do I modify it so that rather than bringing every field from one table into the resulting table it brings only columns (from both tables) that are explicitly defined?

I'm modifying another process to use the same approach, that was done in Query Builder where the Join was defined and columns chosen, so I want to mimic that rather than get the right output in a second step.

Thanks again!
paulrockliffe
Obsidian | Level 7

I should add I modified the code to simply import from a particular table rather than stitch tables together as well.  I want to be able to add conditions to this import. New code is:

 

data Want;

 

if _n_ = 1 then do;

 

declare hash l (dataset:"Server.Lookup");

l.definekey("Ref");

l.definedone();

 

end;

 

set Server.Data;

if l.check() = 0;

 

run;

 

I'd also like to be able to limit the data coming in by adding where clauses to the above eg, where Date_Column > &Date then yes, otherwise no.

 

Thanks!

paulrockliffe
Obsidian | Level 7

Thanks, I think I can work that out.  I've spent all afternoon reading about hash tables and I'm struggling with getting the output table to include variables from both the has table and the table I'm filtering.  Some pointers for that would be really helpful.

 

Cheers

paulrockliffe
Obsidian | Level 7

Thanks, I managed to get that far, the bit I can't work out is how I output both variables from the hash table and variables from the table I'm using the hash table to subset, all in a single table. 

 

I'm essentially trying to do an inner join between the two tables and select columns from both.  I'm only able to get data from one table or the other.

paulrockliffe
Obsidian | Level 7

Thanks, the only value common to each table and with the same name is the one I'm using as the key.  If I only want to take that value from either table, not both, then does it still need to be renamed?  Can I not just not include the key when I use definedata?

Kurt_Bremser
Super User

At this point it is necessary for us to know the structures of the datasets involved, and have a picture about the types and other attributes of the variables.

The best way to do this is to post a simplified example of your "big" and "small" datasets in data steps with datalines; for these we can then design code that works (as we have something to test against), and which you can later expand to your real-life situation.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 24 replies
  • 5795 views
  • 0 likes
  • 6 in conversation