- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Retrieve the nobs from dictionary.tables or sashelp.vtable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
noobs is blank. is there any macro which can help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
some i am getting dots(.) in nobs, i am not getting any values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Don't feed me meaningless oneliners, POST YOUR CODE. And run mine AS IT IS, so you get a reference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 | . |
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sql; select sum(nobs) from sashelp.vtable where libname="YOURLIB"; quit;
Replace yourlib with your libname, and make sure its upper case.