How to get the count of total records from all the tables in a library. I have one library with multiple datasets. I want to know what is the number of records in each of the tables. how can I do it?
If your data library points to a database -- not a folder of SAS data sets -- then NOBS might might not be available in the metadata that SAS can see. Instead, you might need to use PROC SQL with COUNT(*) or issue a database-specific query using PROC SQL and the CONNECT clause.
Also, if the library is a folder of SAS files but they are VIEW type and not DATA, then you won't be able to see the record count in the metadata.
Retrieve the nobs from dictionary.tables or sashelp.vtable.
noobs is blank. is there any macro which can help.
@Srigyan wrote:
noobs is blank. is there any macro which can help.
"noobs" is an option for proc print. Read my post thoroughly.
Here is some code for reference:
data class;
set sashelp.class;
run;
data cars;
set sashelp.cars;
run;
proc sql;
select sum(nobs) as nobs from dictionary.tables where libname = 'WORK' and memtype = 'DATA';
select memname, nobs from dictionary.tables where libname = 'WORK';
quit;
Result:
nobs -------- 455 Number of Physical Member Name Observations ---------------------------------------------- CARS 428 CLASS 19 _PRODSAVAIL 8
some i am getting dots(.) in nobs, i am not getting any values.
Don't feed me meaningless oneliners, POST YOUR CODE. And run mine AS IT IS, so you get a reference.
proc sql;
select sum(nobs) as nobs from dictionary.tables where libname = 'G2NONPII' and memtype = 'DATA';
select memname, nobs from dictionary.tables where libname = 'G2NONPII';
quit;
its giving me
TABLE NAME | Nobs |
T1 | . |
T2 | . |
T3 | . |
If your data library points to a database -- not a folder of SAS data sets -- then NOBS might might not be available in the metadata that SAS can see. Instead, you might need to use PROC SQL with COUNT(*) or issue a database-specific query using PROC SQL and the CONNECT clause.
Also, if the library is a folder of SAS files but they are VIEW type and not DATA, then you won't be able to see the record count in the metadata.
proc sql; select sum(nobs) from sashelp.vtable where libname="YOURLIB"; quit;
Replace yourlib with your libname, and make sure its upper case.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.