Thanks for all the help. I probably should have given a somewhat clearer sample code to illustrate what I needed. Here's the solution that I went with: /* End a loop when a dataset no longer has any obs */ /* Initial dataset */ Data ds_0; input x $ y; datalines; a 2 b 7 c 17 ; Run; /* Observations in ds_1 will be subject to repeated loops until achieving a passing value */ Data ds_1; set ds_0; Run; /* ********************************* */ /* ********************************* */ %macro looper; %do %until(&num = 0); /* perform algorithm */ /* note: the algorithm will actually be a complex series of data steps and sql statements */ Data ds_2; set ds_1; z=3*y; Run; /* split the dataset based upon results */ Data ds_3 ds_4; set ds_2; if z < 50 then output ds_4; if z > 49 then output ds_3; Run; proc append base=ds_complete data=ds_3 force; run; %let dsid=%sysfunc(open(ds_4)); %let num=%sysfunc(attrn(&dsid, nobs)); %let rc=%sysfunc(close(&dsid)); %if &num = 0 %then %return; Data ds_1; set ds_4; y=z; drop z; Run; %end; %mend; %looper;
... View more