DATA Step, Macro, Functions and more

Number of datasets in library

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 145
Accepted Solution

Number of datasets in library

Dear All,

 

Can some one help me in writing number of dataset in a library into a macro variable.

 

For example:

 

If a library x has 50 datasets. I should get the value of 50 in macro variable.

 

Thanks

Rakesh


Accepted Solutions
Solution
‎07-17-2017 04:01 PM
Super User
Posts: 11,343

Re: Number of datasets in library

Posted in reply to rakeshvvv

Replace LIBRARY with the name of the library you want to use. The library names are kept in all capital letters in the table.

proc sql;
   select count(memname) into : dscount
   from dictionary.members
   where libname='LIBRARY' and memtype='DATA';
quit;

%put &dscount;

View solution in original post


All Replies
Occasional Contributor
Posts: 7

Re: Number of datasets in library

Posted in reply to rakeshvvv

Try this:

 

proc sql noprint;
select count(memname) into :number
from sashelp.vmember
where libname='CCARLIB' and memtype='DATA';
quit;

 

This example sets the macrovariable &number with the number of datasets in the CCARLIB library.

 

Regards,

 

 

 

Solution
‎07-17-2017 04:01 PM
Super User
Posts: 11,343

Re: Number of datasets in library

Posted in reply to rakeshvvv

Replace LIBRARY with the name of the library you want to use. The library names are kept in all capital letters in the table.

proc sql;
   select count(memname) into : dscount
   from dictionary.members
   where libname='LIBRARY' and memtype='DATA';
quit;

%put &dscount;
Regular Contributor
Posts: 227

Re: Number of datasets in library

Posted in reply to rakeshvvv

for more information use this code

 

PROC sql noprint;
         create table list_memnames as
         select libname,
                monotonic() as memnum label='member number',
                memname, nobs,   nvar as nvars,   memlabel
         from   dictionary.tables
         where  libname eq "%upcase(&libname)"
           and  memtype eq 'DATA';
         quit;

 

Ron Fehd 

☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 270 views
  • 2 likes
  • 4 in conversation