/***************************************************************************************************************** SAS file name: numobs.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate different approaches to determining the number of observations in a SAS data set without reading the entire data. Author: Peter Clemmensen Creation Date: 10/02/2020 This program supports the blog post "Find Number of Observations in SAS Data Set" on SASnrd.com *****************************************************************************************************************/ /* Using the Nobs= option (set at compile time */ data _null_; set sashelp.class nobs=n; call symputx('nobs',n); stop; run; %put nobs=&nobs; /* Using Open, Attrn and Close Functions wrapped in %sysfuncs */ %let dsid=%sysfunc(open(sashelp.class)); %let nobs=%sysfunc(attrn(&dsid,nlobs)); %let dsid=%sysfunc(close(&dsid)); %put nobs= &nobs ; /* Retrieve information from metadata */ data _null_; set sashelp.vtable; where libname='SASHELP' & MEMNAME='CLASS'; call symputx('nobs',nobs); run; %put nobs= &nobs ;