I have a dataset with 2 columns of ID numbers (id1 id2). Each row establishes a link between 2 ID numbers There are several many-to-many links, and some ID numbers appear in both columns. I want to create a "group-ID" for all IDs which are interlinked with each other. How can I do this?
In the example below, I want to create 2 group IDs: one for ID numbers a b c d, and another for ID numbers e f.
data have;
input (id1 id2) (:$1.);
cards;
a b
a c
b d
e f
;
Thanks for your help.
Karen
If you have SAS/OR licensed then look at PROC BOM.
If not, there's a good solution posted on here earlier that some searching may help find.
Thank for your answer, but I do not have SAS/OR.
I used the macro SubGraphs as suggested by PG, which works very well
Karen
I don't have SAS/OR anymore either, so I'm glad to see PG's macro as well!
It works wonderfully.
Thank you very much
Karen
@Reeza - I fixed the link to point to the proper article.
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.