Hello I have one table (Table A) which has info about our clients. Their names, ID's, products owned, address etc etc. Most clients will have multiple entries since they own multiple products. I need to extract information for 50 or so clients from that list, these required clients name are present in a different table (Table B). If I try using an if statement that would take forever to write down all 50 clients name plus leaves room for a lot of error. I was wondering if there is a faster way to do this. I considered doing a left join but not sure if this would work since Table A would have multiple entries under the clients name and the name repeated many times while Table B would not have any repeats.
Thanks in advance!
Hi Thanks for the quick reply. I want to keep the repeats. I want all the information for client from Table B (The one with multiple entries of client name) based on which clients are mentioned in Table A (The table with single entries of client names)
Use a hash object:
data want;
set a;
if _n_ = 1
then do;
declare hash b (dataset:"b");
b.definekey("id");
b.definedone();
end;
if b.find() = 0;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.