data have;
input ID $ Q12 $15.;
cards;
1 1,2,3,4,5
2 4,11,13
3 6,7,8,9,10,11
4 .
5 1,19
6 .
;
run;
data want;
set have;
len=length(Q12);
array q[*] Q1-Q6;
do i=1 to len;
call scan(Q12,i,pos,ln,',');
if not pos then
leave;
if input(substrn(q12,pos,ln),8.) then
q[i]=1;
end;
do j=1 to dim(q);
if missing(q[j]) then
q[j]=0;
end;
drop pos ln i len j;
run;