不太理解是不是没搞明白 你嵌套循环的目的 我改写了一下 可以运行, 你看看结果
%let EXDS=%str(a|b|bc|bcd);
%let nstudy=4;
%let EXN=%str(1|2|3|4);
%put &=nstudy &=EXDS &=exn;
%global exn EXDS nstudy j EX_1 EX_2 EX_3 EX_4;
%macro adsl;
%do j=1 %to &nstudy.;
%let EXDSC=%scan(&EXDS,&j,'|');
%put &=EXDSC &=j;
%put &=EXN;
%let EXcN=%scan(&EXN,&j.,'|');
%put &=EXcN;
%do i=1 %to &EXcN.;
%let EX_&i=%scan(&EXDSC,&i,'|');
%put &=EX_1 &=EX_2 &=EX_3 &=EX_4;
%end;
%end;
%mend;
%adsl;
结果:
EXDSC=a J=1
EXN=1|2|3|4
EXCN=1
EX_1=a EX_2= EX_3= EX_4=
EXDSC=b J=2
EXN=1|2|3|4
EXCN=2
EX_1=b EX_2= EX_3= EX_4=
EX_1=b EX_2= EX_3= EX_4=
EXDSC=bc J=3
EXN=1|2|3|4
EXCN=3
EX_1=bc EX_2= EX_3= EX_4=
EX_1=bc EX_2= EX_3= EX_4=
EX_1=bc EX_2= EX_3= EX_4=
EXDSC=bcd J=4
EXN=1|2|3|4
EXCN=4
EX_1=bcd EX_2= EX_3= EX_4=
EX_1=bcd EX_2= EX_3= EX_4=
EX_1=bcd EX_2= EX_3= EX_4=
EX_1=bcd EX_2= EX_3= EX_4=
|