The DESCRIBE TABLE Statement

A Brief Overview

Suppose you want to view the table structure of a table which you or someone else created. The structure of a table includes the columns and the column attributes. When you create a table, the CREATE TABLE statement writes a message to the SAS log, which indicates the number of rows and columns in the table that was created. However, the message does not contain information about column attributes.
If you are working with an existing table that contains rows of data, you can use a PROC SQL query to generate a report that shows all of the columns in a table. However, the report does not list the column attributes, and a PROC SQL query will not generate output for an empty table.
The DESCRIBE TABLE statement writes to the SAS log a CREATE TABLE statement that includes column definitions for the specified table, regardless of how the table was originally created. For example, if the DESCRIBE TABLE statement specifies a table that was created with the DATA step, a CREATE TABLE statement is still displayed.

DESCRIBE TABLE Statement Syntax

To display a list of columns and column attributes for one or more tables in the SAS log, regardless of whether the tables contain rows of data, you can use the DESCRIBE TABLE statement in PROC SQL.
Syntax, DESCRIBE TABLE statement:
DESCRIBE TABLE table-name-1<, ... table-name-n>;
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
Tip
As an alternative to the DESCRIBE TABLE statement, you can use other SAS procedures, like PROC CONTENTS, to list a table's columns and column attributes. PROC CONTENTS generates a report instead of writing a message to the SAS log, as the DESCRIBE TABLE statement does.

Example: Displaying the Structure of a Table

The empty table Work.Discount was created by using the CREATE TABLE statement and column specifications shown below:
proc sql;
   create table work.discount 
         (Destination char(3),
          BeginDate num format=date9.,
          EndDate num format=date9.,
          Discount num);
quit;
The following DESCRIBE TABLE statement writes a CREATE TABLE statement to the SAS log for the table Work.Discount:
proc sql;
   describe table work.discount;
quit;
Log 2.7 SAS Log
NOTE: SQL table WORK.DISCOUNT was created like:

create table WORK.DISCOUNT( bufsize=65536 )
  (
   Destination char(3),
   BeginDate num format=DATE9.,
   EndDate num format=DATE9.,
   Discount num
  );

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