Using Dictionary Tables

A Brief Overview

Metadata is a description or definition of data or information.
SAS session metadata is stored in Dictionary tables, which are special, Read-Only SAS tables that contain information about SAS libraries, SAS data sets, SAS macros, and external files that are available in the current SAS session. Dictionary tables also contain the settings for SAS system options and SAS titles and footnotes that are currently in effect. Dictionary tables are commonly used to monitor and manage SAS sessions because the data is easier to manipulate than the output from procedures. You can use the SQL procedure to access the metadata stored in Dictionary tables. For example, you can query a Dictionary table to find out which tables in a SAS library contain a specified column.
The following statements are true about Dictionary tables:
  • They are created each time they are referenced in a SAS program.
  • They are updated automatically.
  • They are limited to Read-Only access.
Accessing a Dictionary table causes SAS to determine the current state of the SAS session and return the information that you want. Dictionary tables can be accessed by running a PROC SQL query against the table, using the Dictionary libref. Though SAS librefs are usually limited to eight characters, Dictionary is an automatically assigned, reserved word. You can also access a Dictionary table by referring to the PROC SQL view of the table that is stored in the Sashelp library.
The following table describes some of the Dictionary tables that are available and lists the corresponding Sashelp views. For a complete list of Dictionary tables, see the SAS documentation for the SQL procedure.
Dictionary Table
Sashelp View
What the Table Contains
Catalogs
Vcatalg
information about catalog entries
Columns
Vcolumn
detailed information about variables and their attributes
Extfiles
Vextfl
currently assigned filerefs
Indexes
Vindex
information about indexes defined for data files
Macros
Vmacro
information about both user and system defined macro variables
Members
Vmember
Vsacces
Vscatlg
Vslib
Vstable
Vstabvw
Vsview
general information about data library members
Options
Voption
current settings of SAS system options
Tables
Vtable
detailed information about data sets
Titles
Vtitle
text assigned to titles and footnotes
Views
Vview
general information about data views

Example: Exploring and Using Dictionary Tables

You can query Dictionary tables the same way that you query any other table, including subsetting with a WHERE clause, ordering the results, creating tables, and creating PROC SQL views. Because Dictionary tables are Read-Only objects, you cannot insert rows or columns, alter column attributes, or add integrity constraints to them.
To see how each Dictionary table is defined, submit a DESCRIBE TABLE statement. The DESCRIBE TABLE statement writes a CREATE TABLE statement to the SAS log for the table that is specified in the DESCRIBE TABLE statement. After you know how a table is defined, you can use its column names in a subsetting WHERE clause in order to retrieve specific information.
The Dictionary.Tables table contains detailed information about tables. The following DESCRIBE TABLE statement displays information about the Dictionary.Tables table in the log window. The information includes the names of the columns that are stored in the table.
proc sql;
   describe table dictionary.tables;
quit;
Log 2.8 SAS Log
create table DICTIONARY.TABLES  
  (  
   libname char(8) label='Library Name', 
   memname char(32) label='Member Name', 
   memtype char(8) label='Member Type', 
   memlabel char(256) label='Dataset Label',  
   typemem char(8) label='Dataset Type', 
   crdate num format=DATETIME informat=DATETIME label='Date Created', 
...);
To display information about the files in a specific library, specify the column names in a SELECT statement and the Dictionary table name in the FROM clause.
For example, the following PROC SQL step displays these columns:
  • Memname (name)
  • Nobs (number of observations)
  • Nvar (number of variables)
  • Crdate (creation date) of the tables in the Certadv library
The Dictionary column names are specified in the SELECT statement, and the Dictionary table name, Dictionary.Tables, is specified in the FROM clause. The library name, Certadv, is specified in the WHERE clause.
Note: You must specify the library name in the WHERE clause in uppercase letters, because that is how it is stored within SAS, and enclose it in quotation marks.
proc sql;
   select memname format=$20., nobs, nvar, crdate
      from dictionary.tables
      where libname='CERTADV';
quit;
Output 2.7 Dictionary.Tables of Certadv (partial output)
Partial Output of Dictionary.Tables of Certadv
Note: The number of physical observations value for ALL is missing because ALL is a view, not a table.
Note: Your output might differ from that shown above, depending on the contents of your Certadv library.
You can also use Dictionary tables to determine more specific information such as which tables in a SAS library contain a specific column.
Last updated: October 16, 2019
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset