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!
You can add additional conditions to the subsetting if.
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
If you need the lookup hash to also deliver data, use the definedata() method to add data variables
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.
If you have variables with identical names in both tables, you must rename them in one table to keep their values.
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?
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.