USE OF NOOBS | OBS | _N_ | N options

Use of NOOBS  

It is used for Suppress column which tells the row/observation number in Proc print.

Example - See both outputs with NOOBS and without NOOBS

Proc Print Data=SASHELP.CARS;
WHERE MAKE='Audi';
RUN;

Proc Print Data=SASHELP.CARS NOOBS;
WHERE MAKE='Audi';
RUN;

Use of Noobs

 Use of OBS  and N options - 

OBS option give the Actual row number from the original dataset, for example in below code output, row number starts from 8 because First row of Audi car in source dataset is available at 8th position


Proc PRINT data=SASHELP.cars N OBS;
where Make='Audi';
run;

Use of OBS and N - Datahark

N Option gives the Total count of observation in dataset.

Use of _N_ 

As I already explained in  my previous post for PDV - there are two automatic variables are being created in datastep these are - _N_ and _ERROR_

_N_ counts the Number of times Datastep begin to execute.

For Example - if we want to print the top 10 rows of any dataset - 

data test;
set SASHELP.CARS;
N=_N_;
if _n_<=10;
run;

Use of _N_ = Datahark



Post a Comment

0 Comments