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

Hello Techiez,

 

I need help to get total count of observation in all dataset from a Library.

 

Suppose a library contains 50 datasets(tables).

 

Some table have X observation , some has Y observation.

 

Want total count of all the datasets.

 

thanks in advance.

 

Regards,

Ritesh

1 ACCEPTED SOLUTION

Accepted Solutions
nehalsanghvi
Pyrite | Level 9

This example uses work library, but you can substitute your own lib:

proc sql;
select sum(nobs) as TotalRows
from dictionary.tables
where libname eq 'WORK';
quit;

 

 

View solution in original post

4 REPLIES 4
nehalsanghvi
Pyrite | Level 9

This example uses work library, but you can substitute your own lib:

proc sql;
select sum(nobs) as TotalRows
from dictionary.tables
where libname eq 'WORK';
quit;

 

 

Riteshdell
Quartz | Level 8

thanks nehalsanghv you really solved my query.

 

A new question came to my mind realted to same.

 

Suppose A library contains 100 dataset, and i want only 50 dataset count ( selective dataset).

 

Is it possible?

 

thanks in advance.

 

Regards,

Ritesh

 

 

nehalsanghvi
Pyrite | Level 9

Dataset names are listed in the memname column of dictionary.tables. You can list the memname values you want in the where statement. Give the entire dictionary table a look with a select *, there is a lot of useful metadata.

proc sql;
select sum(nobs)
from dictionary.tables
where libname = 'WORK'
and memname in ('TBL1','TBL2'); quit;
Ksharp
Super User

Better use NLOBS .

 

proc sql;
select sum(nlobs) as TotalRows
from dictionary.tables
where libname eq 'WORK' and memname like '%XX%';
quit;

sas-innovate-2024.png

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.

 

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
  • 4 replies
  • 2353 views
  • 1 like
  • 3 in conversation