turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- How can I get total counts of observations of 100 ...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-22-2017 02:18 PM

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

Accepted Solutions

Solution

02-22-2017
02:40 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-22-2017 02:33 PM - edited 02-22-2017 02:33 PM

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;
```

All Replies

Solution

02-22-2017
02:40 PM

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-22-2017 02:33 PM - edited 02-22-2017 02:33 PM

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;
```

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-22-2017 02:40 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-22-2017 02:46 PM

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;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

02-22-2017 09:55 PM

Better use NLOBS .

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