Displaying Index Specifications

Overview

Sometimes you want to know whether an existing table has any indexes. To display a CREATE INDEX statement in the SAS log for each index that is defined for one or more specified tables, you can use the DESCRIBE TABLE statement. (The DESCRIBE TABLE statement also writes a CREATE TABLE statement to the SAS log for each specified table.)
General form, DESCRIBE TABLE statement:
DESCRIBE TABLE table-name-1<, ... table-name-n>;
Here is an explanation of the syntax:
table-name
specifies the table to be described as one of the following:
  • a one-level name
  • a two-level libref.table name
  • a physical pathname that is enclosed in single quotation marks.
If a specified table has no indexes, a CREATE INDEX statement does not appear.

Example

Earlier in this chapter, the following code was used to create a unique composite index named daily on the columns FlightNumber and Date in the temporary table Marchflights.
proc sql;
   create unique index daily
      on work.marchflights(flightnumber,date);
The following DESCRIBE TABLE statement writes a CREATE INDEX statement to the SAS log (after the CREATE TABLE statement) for the table Marchflights:
proc sql;
   describe table marchflights;
Table 6.5 SAS Log
NOTE: SQL table WORK.MARCHFLIGHTS was created like:

create table WORK.MARCHFLIGHTS( bufsize=8192 )
  (
   Date num format=DATE9. informat=DATE9.,
   DepartureTime num format=TIME5. informat=TIME5.,
   FlightNumber char(3),
   Origin char(3),
   Destination char(3),
   Distance num,
   Mail num,
   Freight num,
   Boarded num,
   Transferred num,
   NonRevenue num,
   Deplaned num,
   PassengerCapacity num
  );
create unique index daily on WORK.MARCHFLIGHTS(FlightNumber,Date);
If the table Marchflights had no index defined, no CREATE INDEX statement would appear in the SAS log.

Alternatives to the DESCRIBE TABLE Statement

The DESCRIBE TABLE statement is only one of several methods that can be used to list information about indexes that are defined on a table. One alternative is to query the special table Dictionary.Indexes, which contains information about indexes that are defined for all tables that are known to the current SAS session. (Dictionary.Indexes is one of many read-only dictionary tables that are created at PROC SQL initialization. These tables contain information about SAS libraries, SAS macros, and external files that are in use or available in the current SAS session.)
You can also use other SAS procedures, such as PROC CONTENTS and PROC DATASETS, to generate a report that contains information about indexes.
Note: To learn more about the use of dictionary tables, see Managing Processing Using PROC SQL. To learn more about using PROC CONTENTS and PROC DATASETS, see Creating Indexes.
..................Content has been hidden....................

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