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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.