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 

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
  • 3 replies
  • 8932 views
  • 2 likes
  • 4 in conversation