DATA Step, Macro, Functions and more

How to find all the datasets in a library with zero observation and create a dataset with the dataset names?

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,636
Accepted Solution

How to find all the datasets in a library with zero observation and create a dataset with the dataset names?

Hi All,

I need to find all the datasets with zero observation in a library. How should I do that? Any suggestion is highly appreciated.

Thanks - Linlin


Accepted Solutions
Solution
‎12-19-2012 10:02 AM
Respected Advisor
Posts: 3,124

Re: How to find all the datasets in a library with zero observation and create a dataset with the dataset names?

Linlin,

Could you use dictionary.tables to find your info? there is a variable 'nobs' delivering what you need.

Haikuo

View solution in original post


All Replies
Solution
‎12-19-2012 10:02 AM
Respected Advisor
Posts: 3,124

Re: How to find all the datasets in a library with zero observation and create a dataset with the dataset names?

Linlin,

Could you use dictionary.tables to find your info? there is a variable 'nobs' delivering what you need.

Haikuo

Super Contributor
Posts: 1,636

Re: How to find all the datasets in a library with zero observation and create a dataset with the dataset names?

Hi Haikuo,

Thank you very much! - Linlin

My code:

proc sql;

  create table want as

    select memname,nobs

   from dictionary.tables

     where libname='WORK' and memname like "_%" and nobs=0;

  quit;

proc print data=want;

run;

Super User
Posts: 9,687

Re: How to find all the datasets in a library with zero observation and create a dataset with the dataset names?

Recommend you use nlobs to instead fo nobs.

When Some data set be modified directly ,not random modified, NOBS will return not exactly the nobs.

Super Contributor
Posts: 1,636

Re: How to find all the datasets in a library with zero observation and create a dataset with the dataset names?

Good point. Thank you Ksharp! - Linlin

New Contributor
Posts: 2

Re: How to find all the datasets in a library with zero observation and create a dataset with the dataset names?

proc sql noprint;

create table temp/* if you want it use in a dataset*/ as select libname as library_name,

memname as Name

from sashelp.Vtable where Libname="Work" /* you can use any library*/

and nobs=0;

select count(*)

into:Nobs

from temp;

Select Name

into :Name1-:Name%left(&Nobs)

from temp;

quit;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 292 views
  • 4 likes
  • 4 in conversation