Hello Spud,
Could you try this?
proc sql;
create table T02_contains as
select a.var, count(distinct b.var) as count_distinct, (calculated count_Distinct gt 0) as flag_exist
from T01_table1 a LEFT JOIN T01_table2 b
on index(a.var,trim(b.var)) gt 0
group by 1;
quit;
I tested it with the following data sets:
* Test data;
data T01_table2;
infile cards;
length var $30;
input var;
cards;
var
it
is
fi
;
run;
data T01_table1;
infile cards;
length var $30;
input var;
cards;
fit
food
his
you
hit
item
;
run;
Watch out: it will perform a cartesian product. As a consequence, it is time and resource consuming. But I think it will do what you want.
Could you let me know whether this helped,
Regards,
Yoba