If you allow to sort the content of column A, then prxchange can be used:
data have;
infile datalines truncover;
input a $11.;
datalines;
a, b
c, b, c
a, b, b,c,a
d
;
data want;
set have;
array _dummy_[100] $1 _temporary_;
call missing(of _dummy_[*]);
cmpres_a=compress(a,' ,');
call pokelong(cmpres_a,addrlong(_dummy_[1]),length(cmpres_a));
call sort(of _dummy_[*]);
new_a=prxchange('s/\b(\w), (\1)\b/$1/',-1,catx(', ',of _dummy_[*]));
put new_a=;
run;
The result will be:
new_a=a, b
new_a=
new_a=b, c
new_a=a, b, c
new_a=d
... View more