Using Dictionary Tables

Overview

Dictionary tables are commonly used to monitor and manage SAS sessions because the data is easier to manipulate than the output from procedures such as PROC DATASETS.
Dictionary tables are special, read-only SAS tables that contain information about SAS libraries, SAS macros, and external files that are in use or 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. For example, the Dictionary.Columns table contains information (such as name, type, length, and format) about all columns in all tables that are known to the current SAS session.
Dictionary tables are
  • created each time they are referenced in a SAS program
  • updated automatically
  • 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
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
VmemberVsaccesVscatlgVslibVstableVstabvwVsview
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

Exploring and Using Dictionary Tables

You can query Dictionary tables the same way 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 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.

Example

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 stored in the table.
proc sql;
   describe table dictionary.tables;
Table 8.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 the columns
  • Memname (name)
  • Nobs (number of observations)
  • Nvar (number of variables)
  • Crdate (creation date) of the tables in the Sasuser 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, Sasuser, is specified in the WHERE clause.
CAUTION:
Note that 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='SASUSER';
Partial output is shown below.
Dictionary.Tables
Note: The nobs value for ALL is missing because it is a view, not a table.
Note: Your output might differ from that shown above, depending on the contents of your Sasuser library.
You can also use Dictionary tables to determine more specific information such as which tables in a SAS library contain a specific column.

Example

The Dictionary.Columns table contains detailed information about variables and their attributes. As in Dictionary.Tables, the Dictionary.Columns table contains a column that is titled Memname, which lists the name of each table within a library.
proc sql;
   describe table dictionary.columns;
Table 8.9 SAS Log
create table DICTIONARY.COLUMNS  
  (   
   libname char(8) label='Library Name',  
   memname char(32) label='Member Name', 
   memtype char(8) label='Member Type', 
   name char(32) label='Column Name', 
   type char(4) label='Column Type', 
   length num label='Column Length',
...);
The following PROC SQL step lists all the tables in the Sasuser library that contain a column named EmpID. The dictionary column name, Memname, is specified in the SELECT statement. The Dictionary table, Dictionary.Columns, is specified in the FROM clause. The library name, Sasuser, and the column name, EmpID, are specified in the WHERE clause.
proc sql;
   select memname
      from dictionary.columns
      where libname='SASUSER'
            and name='EmpID';
Partial output is shown below.
Partial output
Remember that you can also access a Dictionary table by referring to the PROC SQL view of the table that is stored in the Sashelp library. In the following PROC PRINT step, the Sashelp view Vcolumn is specified in the DATA= option. The results of the PROC PRINT step are identical to the preceding output.
proc print data=sashelp.vcolumn;
   var memname;
   where libname='SASUSER' and name='EmpID';
run;
CAUTION:
Note that column names in the WHERE clause must be specified in the same case that is used in the Dictionary table and must be enclosed in quotation marks.
Note: You can use Sashelp views in any SAS procedure or DATA step. However, Dictionary tables can be read only by using the SQL procedure.
..................Content has been hidden....................

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