Hi:
_N_ is only available as an automatic variable in a DATA step program. PROC PRINT has another (different) method for showing OBS number in it's output.
The OBS= and FIRSTOBS= options allow you to select observations, however, you will need 1 step for OBS=10-20 and another step for obs 40-50, as shown in the program below. SASHELP.SHOES has 358 observations... I created an ORIGOBS column just to prove that FIRSTOBS and OBS worked.
Do remember that if your input dataset somehow gets sorted that different observations might be selected in subsequent runs of your PROC REPORT code. Also, after using OBS= and FIRSTOBS= options, you will want to set the limit back to OBS=MAX and FIRSTOBS=1 so that subsequent procedures are not impacted by these options.
cynthia
[pre]
options obs=max firstobs=1;
data shoes;
set sashelp.shoes;
origobs = _n_;
run;
ods html file='c:\temp\useobs_firstobs.html' style=sasweb;
options obs=10 firstobs=1;
proc report data=shoes nowd;
title 'firstobs=1 obs=10';
run;
options obs=50 firstobs=40;
proc report data=shoes nowd;
title 'firstobs=40 obs=50';
run;
ods html close;
options obs=max firstobs=1;
[/pre]
** use this code to reset BOTH options:
[pre]
options obs=max firstobs=1;
[/pre]
Message was edited by: Cynthia@sas