You may have to fix my syntax here, but this approach should work:
proc sql;
create table matches as select a.*, b.id2 as matching_id2, b.id3 as matching_id3 from
have a, have b
where a.id1 ne b.id1 and (a.id1=b.id2 or a.id1=b.id3);
quit;
Can you post some sample data please.
You may have to fix my syntax here, but this approach should work:
proc sql;
create table matches as select a.*, b.id2 as matching_id2, b.id3 as matching_id3 from
have a, have b
where a.id1 ne b.id1 and (a.id1=b.id2 or a.id1=b.id3);
quit;
It looks like you dropped the word "FROM" within the SELECT statement.
The word HAVE (or HAVING) is supposed to represent the name of your data set. Most solutions that are posted here will use WANT as the name of the data set you want to obtain, and HAVE as the name of the data set you are starting with. So just replace that with the name of your data set.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.