%macro a(x);
data a;
do i=1 to 100;
y=substr("&x",i,1);
if y^=. then n+1;
if y=. then leave;
end;
call symput('num',n);
run;
%put # /*算出数字有几位并赋值给宏变量num*/
data b;
do i=1 to #
y=substr("&x",i,1);
if y='1' then do;
n+1;
output;/*i为数字中哪几位是数字1*/
end;
if y=. then leave;
end;
call symput('num_1',n);
run;
%put &num_1;/*算出数字中有几个1并赋值给宏变量num_1*/
%do j=1 %to &num_1;
data c;
set b;
if _n_=&j;
data d;
set c;
call symput("num_1_&j",i);
run;
%put &&num_1_&j;/*输出数字中1所在的位置,这个变量应该输出1,2,5,同时把这3个值赋值宏变量num_1_1 num_1_2 num_1_3*/
%end;
run;