UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

SAS FAQ
How do I display information for all the SAS datasets in a directory?

Let's say that we have a number of SAS data files in a directory and we need to know the number of observations and the number of variables in each data set. Of course, we can always use proc contents on each of the data set, but it can get tedious and the output will get too long really quickly.

There is an easy solution by using the SAS data file sashelp.vtable that SAS creates and updates during an active SAS session.

Here is an example. Let's say we have a directory called c:\data\dissertation and it contains many SAS files. Here is the sas code to display all the SAS files in the directory with information on the number of observations and the number of variables.

libname dis 'c:\data\dissertation';
proc print data  =  sashelp.vtable (where = (libname="DIS")) noobs;
  var memname nobs nvar;
run;
memname             nobs    nvar

MEDICATION_PP       1242     11
META20                20     10
METARESP             105     14
MISFLAT              831      7
MONKEYS              123      7
MULTRESP             134     12
NHIS_SMALL         30663      7
OPPOSITES_PP         140      6
PEETCOMP             187      9
PEETMIS              269      9
......

You can find more information on data set sashelp.vtable and other v* data sets located in the SASHELP library from this SAS page
The SASHELP Library: It Really Does Help You Manage Data


How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California.