Sometimes you want to look at the
structure (the columns and column attributes) of a table that you
created or of a table that was created by someone else. 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, that 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 does not generate output for an empty table.
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.
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 two-level libref.table name
-
a physical pathname that is enclosed
in single quotation marks.
|
The DESCRIBE TABLE statement
writes a CREATE TABLE statement that includes column definitions to
the SAS log 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.
Note: The DESCRIBE TABLE statement
also displays information about any indexes that are defined on a
table. You can learn more about using the DESCRIBE TABLE statement
to display information about indexes in
Creating and Managing Indexes Using PROC SQL.
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.