![]() Chapter Contents |
![]() Previous |
![]() Next |
| %DO %UNTIL |
| Type: | Macro statement |
| Restriction: | Allowed in macro definitions only |
| See also: | %END |
| Syntax | |
| Details | |
| Example | |
| Validating a Parameter | |
Syntax |
|
%DO %UNTIL (expression);
text and macro language statements |
| %END; |
These examples illustrate expressions for the %DO %UNTIL statement:
| 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 |
%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:
ERROR: PIE type not supported
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.