%DO %UNTIL (expression); text and macro language statements
%END;
Required Argument
expression
can be any macro expression
that resolves to a logical value. The macro processor evaluates the
expression at the bottom of each iteration. The expression is true
if it is an integer other than zero. The expression is false if it
has a value of zero. If the expression resolves to a null value or
a value containing nonnumeric characters, the macro processor issues
an error message.
These examples illustrate
expressions for the %DO %UNTIL statement:
%do %until(&hold=no);
%do %until(%index(&source,&excerpt)=0);
Details
The %DO %UNTIL statement
checks the value of the condition at the bottom of each iteration.
Thus, a %DO %UNTIL loop always iterates at least once.
Example: Validating a Parameter
This example uses the %DO %UNTIL statement to scan
an option list to test the validity of the parameter TYPE.
%macro grph(type);
%let type=%upcase(&type);
%let options=BLOCK HBAR VBAR;
%let i=0;
%do %until (&type=%scan(&options,&i) or (&i>3)) ;
%let i = %eval(&i+1);
%end;
%if &i>3 %then %do;
%put ERROR: &type type not supported;
%end;
%else %do;
proc chart;&type sex / group=dept;
run;
%end;
%mend grph;
When you invoke the
GRPH macro with a value of HBAR, the macro generates these statements:
PROC CHART;
HBAR SEX / GROUP=DEPT;
RUN;
When you invoke the
GRPH macro with a value of PIE, then the %PUT statement writes this
line to the SAS log: