BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Srigyan
Quartz | Level 8

 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?

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

8 REPLIES 8
Srigyan
Quartz | Level 8

noobs is blank. is there any macro which can help.

Kurt_Bremser
Super User

@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
Srigyan
Quartz | Level 8

some i am getting dots(.) in nobs, i am not getting any values.

Srigyan
Quartz | Level 8

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 NAMENobs
T1.
T2.
T3.
ChrisHemedinger
Community Manager

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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
RW9
Diamond | Level 26 RW9
Diamond | Level 26
proc sql;
  select sum(nobs) from sashelp.vtable where libname="YOURLIB";
quit;

Replace yourlib with your libname, and make sure its upper case.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 8484 views
  • 1 like
  • 4 in conversation