1. You can add a few put statement to see where the loop goes.
2. add a _null_ after the data if you don't want output to a dataset.
3. add a nc value to try the loop
when nc = 0.05, you can see that the second if condision is not reached
but when nc=-0.2(which abs(nc) > need ) the second become non-stop because the go to statement. Be carefull about this.
%macro search(w0by,delby,sigby,sig1,sig2,need);
data _null_;
do w0 =0 to 80 by &w0by;
do delta10 =15 to 30 by &delby;
re: do sigma10 =&sig1 to &sig2 by &sigby;
/* loop */ nc=0.05;
put 'Position A ' _all_ ;
if abs(nc)<&need then do;
put 'Position B ' _all_;
/* put w0= delta10= sigma10= nc=;*/
leave; /* this part is for inner loop */
put 'position C ' _all_;
end;
put 'Position D ' _all_;
if nc<0 then do;
put 'Position E ' _all_;
put w0= delta10= sigma10= nc=;
call symputx("sig1",sigma10-&sigby);
call symputx("sig2",sigma10);
call symputx("sigby",&need);
go to re; /* this is for inner loop constraint */
end;
end;
end;
end;
run;
%mend;
%search(10,5,10,50,150,0.1);


雷达卡





京公网安备 11010802022788号







