From: Satya on
Hi friends please help me in solving this problem
I want to find the same set of products purchased by different
customers. Total cutomers are 2500 and each customer ordered 10 to
100 items.
Sample Data set
Data test;
CUTID PROD_ID
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
2 1
2 4
2 6
2 7
2 8
3 1
3 2
3 4
3 9
;
Run;

Same set of products
(1,4)
(1,4,6)
(1,4,6,7)
Etc….

Thanks in advance
From: inason on
See if this helps.

Data test;
input CUTID PROD_ID;
cards;
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
2 1
2 4
2 6
2 7
2 8
3 1
3 2
3 4
3 9
;
Run;

proc sort data=test;
by prod_id;
run;

data want;
set test;
by prod_id;
if last.prod_id + first.prod_id < 2 then output;
run;


IH
From: Tom Abernathy on
Sort by customer and product.
Convert one row per customer using PROC TRANSPOSE.

proc transpose data=test out=testv prefix=prod;
by cutid ;
var prod_id;
run;

To find the unique sets using PROC SORT.

proc sort data=testv nodupkey;
by prod: ;
run;

If you need to find how many occurances of each set then you probably
would want to use PROC SUMMARY.

- Tom
On Jan 8, 4:10 am, inason <iharu...(a)googlemail.com> wrote:
> See if this helps.
>
> Data  test;
> input CUTID PROD_ID;
> cards;
> 1  1
> 1  2
> 1  3
> 1  4
> 1  5
> 1  6
> 1  7
> 1  8
> 2  1
> 2  4
> 2  6
> 2  7
> 2  8
> 3  1
> 3  2
> 3  4
> 3  9
> ;
> Run;
>
> proc sort data=test;
>  by prod_id;
>  run;
>
>  data want;
>   set test;
>    by prod_id;
>    if last.prod_id + first.prod_id < 2 then output;
>    run;
>
> IH