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
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;
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,
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;
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
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.
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.