before getting distracted by the roman numerals, I intended to make use of the SORT FUNCTION since I don't get to use it very much. Anyway, following my own "Juolas" Metatheory I did not want to assume the categories would be alphabetical. BUT maybe we can, and we can use SORT.:
data have;
infile datalines dlm=':';
input ID Categories :$100.;
datalines;
1:(i)cyt,(ii)end therapy,(iii)targ
2:(ii)cyt,(iii)targ,(ii)end therapy
3:(iii)end therapy,(i)cyt,(iii)targ
4:iii)targ,(i)cyt,(ii)end therapy
5:(iii)end therapy,(i)cyt,(iii)targ
6:iii)targ,(i)cyt,(ii)end therapy
7:(i)cyt,(ii)end therapy,(iii)targ
8:(ii)cyt,(iii)targ,(ii)end therapy
9:(ii)cyt
10:(iii)targ
11:(ii)end therapy
;
data want1;
set have;
length cat1-cat3 $20;
array cat[3] $ cat1-cat3;
do i = 1 to 3;/*assuming 3 categories*/
cat[i] = strip(scan(scan(categories,i,","),2,")"));
end;
_rc=sort(of cat1-cat3);
category=catx(", ",of cat1-cat3);
keep id category;
run;
... View more