Hello, PeterC and Ksharp's approaches above create the clone table without giving you the DDL. To get the DDL you can :
proc sql;
describe table sashelp.class;
quit;
and then use the DDL commands written to the log to create the table.
PG
I would have to recommend using the method presented by Peter. The code below will provide insight into why:
proc sql feedback codegen flow;
create table temp (
a num primary key,
b char check (b in ('A','B','C')),
c num not null,
d num,
e char unique );
* check clause constraints are not represented in ddl;
describe table temp;
* no index or constraints are duplicated;
create table temp2 like temp;
describe table temp2;
describe table constraints temp2;
insert into temp (a,b,c,d,e)
values (1,'A',2,3,'!');
quit;
proc append base=new data=temp(obs=0); run;
proc sql;
*now I have everything cloned;
describe table new;
*I did not get data because obs=0 in proc append;
select * from new;
quit;
There are additional options as well, proc copy and proc datasets should be able to clone as well.
Here is a nice piece of reference material to what I discuss:
http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000403555.htm
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.