A macro-ized version:
data have;
sen='the cow jumps over the moon';
run;
%macro want(max=10);
%local max /*maximum combination size*/
S /*combo size index */ ;
data want (drop=ix_:);
set have;
item_count=countw(sen);
if item_count<3 then delete;
length combo $%eval(100+&max*13);
array items{&max} $12 _temporary_;
do I=1 to min(item_count,&max);
items{I}=scan(sen,I,' ');
end;
%do S=1 %to &max;
array ix&S {*} ix_1-ix_&S ;
%end;
do combosize=1 to item_count;
ncomb=comb(item_count,combosize);
ix_1=.;
do c=1 to ncomb;
select (combosize);
%do s=1 %to &max ;
when(&S) call allcombi(item_count,combosize,of ix&S{*});
%end;
end;
combo=' ';
do I=1 to combosize;
combo=catx(' ',combo,items{ix&max{I}});
end;
output;
end;
end;
run;
%mend;
%want(max=15);
As I said earlier, the program is not meant for a variable combination size, which is why it now has to be macro-ized.
... View more