I am trying to find the various combinations only in the cases where the records in the below dataset only differ by the column type. So for example: the first three rows only differ by the column type
Given Dataset
ins_id ins_number type
1234 1234-1234-1 AU
1234 1234-1234-1 HM
1234 1234-1234-1 RE
567 567-567-12 TL
567 567-567-13 TL
9101 9101-1234-1 AU
9101 9101-1234-1 TX
9101 9101-1234-1 CN
8854 8854-1234-1 TX
8854 8854-1234-1 GB
8854 8854-1234-1 RE
8854 8854-1234-2 RX
Expected Output:
combination count
AU,HM,RE 1
AU,TX,CN 1
TX,GB,RE 1
I tried writing the query but I am not getting the desired output, please help:
proc sql;create table tst as select cp.type,
count(distinct ins_id)
from (select distinct fac_prod_typ from dataset3a) cp cross join
(select distinct ins_number from dataset3a) pes left join
dataset3a
on dataset3a.type = cp.type and
dataset3a.ins_number = pes.ins_number
group by cp.type, pes.ins_number;quit;