@dennis_oz:
You can do both WHILE or UNTIL, and the auto-dropped counter _ N_ (or _IORC_ if you wish) can be incorporated into the loop specifications:
data want ;
do _n_ = 1 by 1 while (_n_ <= 10) ;
* do _n_ = 1 by 1 until (_n_ = 10) ;
set sashelp.class ;
output ;
end ;
stop ;
run ;
However, your requirement of using WHILE or UNTIL doesn't make much sense because if you use FROM-TO specification, WHILE is applied implicitly:
data want ;
do _n_ = 1 to 10 ;
set sashelp.class ;
output ;
end ;
stop ;
run ;
I agree with other responders that for a thing like that, you only need the OBS=10 data set option. Or, if you need to select N consecutive records from anywhere in the file, you can combine FIRSTOBS= with OBS=. For example, to select 10 records starting from record 5:
data want ;
set sashelp.class (firstobs=5 obs=14) ;
run ;
Kind regards
Paul D.
... View more