Hi,
I have two datasets dataset a and dataset b.
ex:dataset a
id value
123 xyz
456 wxy
112345 abc
dataset b
id product
123 def
456 tss
789 klm
i want to map product for each id in dataset a from dataset b
final dataset should look like this:
id value product
123 xyz def
456 wxy tss
112345 abc
I'm using left outer join on id....but not getting desired results.
how can i do this.
Thanks,
rk.
A standard left join should work.
ie
proc sql;
create table want as
select a.id, a.value, b.product
from tablea a
left join tableb b
on a.id=b.id;
quit;
You can (should) post your code if something like the above isn't working for you.
Yes,the same code i have if i test on large dataset it is not working.
getting more records than actual records.
Regards,
rk
Your right hand dataset must have duplicate records for the id variables. If they are exact duplicates then adding the DISTINCT keyword after the SELECT keyword will reduce the number of records.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.