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

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

3 REPLIES 3
CatCol
Fluorite | Level 6

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,

 

 

 

ballardw
Super User

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;
Ron_MacroMaven
Lapis Lazuli | Level 10

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 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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