DATA HAVE;
length R_TYP $250. ;
infile datalines ;
input R_TYP;
datalines;
son,daughter
uncle
aunty
son,uncle
;
run;
DATA TEST_MAPPING;
length K_TYP $100. S_TYP $100.;
infile datalines delimiter=',' dsd truncover;
input K_TYP S_TYP;
datalines;
son,family
daughter,family
uncle,extended family
aunty,extended family
;
run;
data want;
if _n_=1 then do;
if 0 then set TEST_MAPPING;
declare hash h(dataset:'TEST_MAPPING');
h.definekey('K_TYP');
h.definedata('S_TYP');
h.definedone();
end;
set have;
length want temp $ 200;
do i=1 to countw(R_TYP,',');
temp=scan(R_TYP,i,',');
if h.find(key:temp)=0 then want=catx(',',want,S_TYP);
else want=catx(',',want,temp);
end;
keep want;
run;
... View more