Further simplified and easy: data table1;
input n text $;
cards;
1 ab
2 abc
3 ad
4 abc
5 hi
;
run;
data table2;
infile cards truncover;
input group1 $ group2 $ group3 $ ;
cards;
ab ad hi
abc
;
run;
data want;
if _n_=1 then do;
if 0 then set table2;
dcl hash H1 (dataset:'table2') ;
h1.definekey ('group1', 'group2','group3') ;
h1.definedone () ;
declare hiter iter('h1');
end;
set table1;
array grp(*) group:;
rc = iter.first();
do while (rc = 0);
do _n_=1 to dim(grp);
if grp(_n_)=text then do; Column_you_would_like=vname(grp(_n_));output;return;end;
end;
rc = iter.next();
end;
stop;
drop rc group:;
run;
... View more