Home » Coding & Data

Describe Your Table in SAS to Write the SQL Code

Submitted by on May 22, 2013 – 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;
quit;

The SAS log provides the create statement:

SQL Describe Code

SAS Support provides additional information on the DESCRIBE statement.

<

Never miss a post!

Get the latest BI Notes post in your Inbox when a new post is released! Click here for free subscription. You email address is kept private and you can unsubscribe anytime. Go ahead ... join us!

The following two tabs change content below.
With about 7 years of experience working with SAS solutions, Steve owns and manages his own SAS-partnered consulting company, Overton Technologies (http://www.overtontechnologies.com), based in Raleigh, North Carolina. He develops SAS Business Intelligence and Data Warehousing solutions specializing in data integration, data architecture design, ETL processing, OLAP technology, systems architecture, dashboards, reporting and analytics. Additional publications and sample code can be found at http://www.stephenoverton.net. Enjoy the knowledge!

Tags: ,

2 Comments »