I'm not sure if I follow the logic in your program.
I'm guessing that in you last data step within the macro loop know if you need to iterate again or not.
If your don't need any more iterations, just call symput to a macro variable a certain value. This together with a %DO %WHILE or %UNTIL logic perhaps can do what you want?
Sorry to not explain well. Yes, my object was to get the number of observations remaining in dataset LOOP to see if I needed to iterate again.
I was trying to use %symput to get the number of observations, but for some reason, I could not get it to work. (an example using call symput would be very welcome - I just now took a look at the documentation, and it's very unclear to me how to use it).
So I went another way and matched the DO UNTIL with PROC SQL to the dictionary table.
Thanks for your help!
%DO %UNTIL (&NUMBOBS = 0) ;
...as before ...
PROC SQL NOPRINT ;
SELECT NOBS INTO :NUMBOBS FROM SASHELP.VTABLE
WHERE LIBNAME='WORK' AND MEMNAME='LOOP' ;
Instead of adding a separate PROC SQL step, you could just modify the last data step as follows. Code additions are documented in comments:
DATA LOOP ;
/* Detect how many observations are in NOTDONE with nobs= */
SET NOTDONE nobs=NumObs;
/* Write the remining number of iterations to the NUMBOBS macro variable */
IF _N_ = 1 THEN DELETE ;