![]() Chapter Contents |
![]() Previous |
![]() Next |
| LEAVE |
| Valid: | in a DATA step |
| Category: | Control |
| Type: | Executable |
| Syntax | |
| Without Arguments | |
| Details | |
| Comparisons | |
| Examples |
Syntax |
| LEAVE; |
The LEAVE statement stops the processing of the current DO loop or SELECT group and continues DATA step processing with the next statement following the DO loop or SELECT group.
| Details |
You can use the LEAVE statement to exit a DO loop or SELECT group prematurely based on a condition.
| Comparisons |
| Examples |
data week;
input name $ idno start_yr status $ dept $;
bonus=0;
do year= start_yr to 1991;
if bonus ge 500 then leave;
bonus+50;
end;
datalines;
Jones 9011 1990 PT PUB
Thomas 876 1976 PT HR
Barnes 7899 1991 FT TECH
Harrell 1250 1975 FT HR
Richards 1002 1990 FT DEV
Kelly 85 1981 PT PUB
Stone 091 1990 PT MAIT
;
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.