BookmarkSubscribeRSS Feed
Abishekaa
Obsidian | Level 7

Is there some way to visualize and calculate intersections among multiple groups? Here is sample data (my data has 7 groups). I want to visualize interactions among all groups to show all the possible results like - 1 patient is in both groups 1 & 2, 2 patients are in both groups 1 & 3, 1 patient is in groups 1,2 &3. Is there some nice way to visualize this? If not, at least a way to calculate and present all the number of participants intersecting at all possible group combinations?  

 

Pt Group1 Group2 Group3
1 0 0 0
2 0 0 0
3 1 1 1
4 1 0 1
5 1 0 0
6 0 1 0
7 0 1 0
8 0 1 1
9 0 1 1
10 0 1 1
1 REPLY 1
Ksharp
Super User

How about this one ?

 

data have;
infile cards expandtabs truncover;
input Pt	Group1	Group2	Group3;
cards;
1	0	0	0
2	0	0	0
3	1	1	1
4	1	0	1
5	1	0	0
6	0	1	0
7	0	1	0
8	0	1	1
9	0	1	1
10	0	1	1
;


data temp;
set have;
length label $ 80;
array g{*} group1-group3;
array x{3};  /*3 is the number of group*/
n=dim(x);nsubs=2**n;k=-1;
do i=1 to nsubs;
rc=graycode(k, of x{*});
 if k>1 then do;  /*only pick up the number of group which is greater than 1*/
   sum=0;
   do j=1 to n;
     sum+g{j}*x{j};
   end;
   if sum=k then do;label=cats(of x{*});output;end;
 end;
end;
keep label;
run;

proc freq data=temp order=freq noprint ;
table label/out=want;
run;

proc sgplot data=want;
hbar label /response=count datalabel;
yaxis label='Group';
xaxis label='the number of patient';
run;

屏幕截图 2026-03-31 145430.png

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 256 views
  • 1 like
  • 2 in conversation