BI Tools

Tips and tricks for building information maps, OLAP cubes, reports, and dashboards

BI Admin

Learn your way around a SAS BI installation.

Visual Analytics

Learn your way around the SAS Visual Analytics tool

Coding & Data

Extract, transform, and load your data into the SAS BI toolset

Stored Processes

Create and design stored processes like a rock star

Home » Coding & Data, General

Describe Your Table in SAS to Write the SQL Code

Submitted by on 2013-05-22 – 6:54 AM 2 Comments

Ever had the need to write SQL create statements for existing tables but felt too lazy to write it by hand?  Ever wanted to reverse engineer tables into SQL code? Have no fear, PROC SQL is here.  Use the DESCRIBE statement to get the full blown SQL code to create the table.  This is particularly good for generating empty table structures to insert data with ETL code.  In the data warehousing world, having SQL code to create empty tables is referred to as the Data Definition Language (DDL).

Example: Describe Statement Using PROC SQL

Running the following describe statement produces the SQL create statement to define the table and columns.

proc sql;
  describe table SASHELP.CLASS;

The SAS log provides the create statement:

SQL Describe Code

SAS Support provides additional information on the DESCRIBE statement.

Never miss a BI Notes post!

Click here for free subscription. Once you subscribe you'll be asked to confirm your subscription through your email account. You email address is kept private and you can unsubscribe anytime.