DATA Step, Macro, Functions and more

Best Way to build SQL statement from a describe table

Reply
New Contributor
Posts: 2

Best Way to build SQL statement from a describe table

In teradata, you can see the table definition by running a show table xxx to get the contents on how it was created.  In SAS you can also run this same code that writes out the contents to a table or perform a describe xxx which produces the code in a log.  what i was looking to do is utilize SAS to read this code to recreate the table to perform a comparison on another table.  The columns could always change so i want to make it as dynamic as possible.  Waht would be the most efficient way to build a new table off of the describe statement.

SAS Super FREQ
Posts: 708

Re: Best Way to build SQL statement from a describe table

If you just want to create a new table that has the same structure as the old table, you can use

create table newTable like oldTable;

See also this sample code here:

data newCars;
  seqNr = _n_;
  set sashelp.cars;
run;

proc sql;
  create index seqNr on newcars;
  describe table newCars;
  create table newCars2 like newCars;
  describe table newCars;
quit;

Bruno

New Contributor
Posts: 2

Re: Best Way to build SQL statement from a describe table

Posted in reply to Bruno_SAS
Thanks for the reply Bruno, ultimately I would take the column attributes that would build the table on Teradata


Super User
Posts: 5,432

Re: Best Way to build SQL statement from a describe table

Perhaps you should look for Teradata tools instead...
Data never sleeps
Ask a Question
Discussion stats
  • 3 replies
  • 197 views
  • 0 likes
  • 3 in conversation