How to find variables and observation count for each dataset in a Library
You can get this information from the SAS dictionary table dictionary.tables. Below an examples for library WORK.
IF there could be any ds in-place delete (i.e. using Proc SQL or data step modify statement) then note that rows don't get deleted physically but only logically. The logically deleted rows get only removed if the table gets physically re-created.
In below example investigate the values in nobs, delobs and nlobs.
data work.class;
set sashelp.class;
run;
proc sql;
delete from work.class
where name='Alfred'
;
quit;
proc sql;
select
libname,
memname,
nvar,
nobs,
delobs,
nlobs
from dictionary.tables
where
libname='WORK'
/* and memname='CLASS'*/
;
quit;
Also: You will get obs counts from libraries pointing to SAS files. Libraries pointing to databases will show missings for nobs/delobs/nlobs.
Databases don't maintain the number of rows in a table as metadata but you need to issue a select count(*) against the table to retrieve such information.
Below code will write to the SAS log what columns/information are available in dictionary.tables
proc sql;
describe table dictionary.tables;
quit;
Hello,
Use the dictionary tables and go on from there.
Do something like:
PROC SQL noprint;
create table abc as
select *
from dictionary.columns
where LIBNAME='MYLIB';
QUIT;
PROC SQL noprint;
create table def as
select *
from dictionary.tables
where LIBNAME='MYLIB';
QUIT;
Cheers,
Koen
try this.
data want;
set sashelp.vtable;
where libname='XXX' and typemem='DATA';/* specify your libname in XXX */
keep memname nobs nvar;
run;
You can get this information from the SAS dictionary table dictionary.tables. Below an examples for library WORK.
IF there could be any ds in-place delete (i.e. using Proc SQL or data step modify statement) then note that rows don't get deleted physically but only logically. The logically deleted rows get only removed if the table gets physically re-created.
In below example investigate the values in nobs, delobs and nlobs.
data work.class;
set sashelp.class;
run;
proc sql;
delete from work.class
where name='Alfred'
;
quit;
proc sql;
select
libname,
memname,
nvar,
nobs,
delobs,
nlobs
from dictionary.tables
where
libname='WORK'
/* and memname='CLASS'*/
;
quit;
Also: You will get obs counts from libraries pointing to SAS files. Libraries pointing to databases will show missings for nobs/delobs/nlobs.
Databases don't maintain the number of rows in a table as metadata but you need to issue a select count(*) against the table to retrieve such information.
Below code will write to the SAS log what columns/information are available in dictionary.tables
proc sql;
describe table dictionary.tables;
quit;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.