Chapter Contents |
Previous |
Next |
LEAVE |
Valid: | in a DATA step |
Category: | Control |
Type: | Executable |
Syntax | |
Without Arguments | |
Details | |
Comparisons | |
Examples |
Syntax |
LEAVE; |
Details |
You can use the LEAVE statement to exit a DO loop or SELECT group prematurely based on a condition.
Comparisons |
Examples |
This DATA step demonstrates using the LEAVE statement to stop the processing of a DO loop under a given condition. In this example, the IF/THEN statement checks the value of BONUS. When the value of BONUS reaches 500, the maximum amount allowed, the LEAVE statement stops the processing of the DO loop.
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.