You're welcome.
Incidentally, the code could be made more flexible like this:
%LET Start = 201205;
%LET Stop = 202101;
PROC SQL ; *noprint;
SELECT
COUNT(TERM) AS Terms_Retreived
INTO :Terms_Retrieved TRIMMED
FROM TERM_REF
WHERE &Start <= Term <= &Stop
;
SELECT
TERM
INTO :Term1 -
FROM TERM_REF
WHERE &Start <= Term <= &Stop
;
QUIT;
%IF %BQUOTE(&Terms_Retrieved) %THEN
%DO;
%put NOTE: &Term1-&&Term&Terms_Retrieved;
%END;
With the above code, you don't need to know in advance how many terms (or which terms) will be retrieved. SAS will figure out how many terms are in the range you specify via the %LET statements, create the appropriate number of macro variables, and display the range in the log for you.
Jim
... View more