Here is one last try:
proc sql;
/* Get the customer IDs */
create table common as
select unique A.ID, A.date
from
tshirt as A,
others as B
where A.ID=B.ID and A.date=B.date;
/* Get what they bought */
create table buys as
select a.id, a.date, a.cloth
from tshirt as a inner join common as b on a.id=b.id and a.date=b.date
union
select a.id, a.date, a.cloth
from others as a inner join common as b on a.id=b.id and a.date=b.date
order by id, date, cloth;
quit;
/* Transform list into a table */
proc transpose data=buys out=buysTable(drop=_name_)
prefix=cloth;
by id date;
var cloth;
run;
... View more