02-01-2012 05:07 AM
I's like to create a new data set that has exactely the same fields as an existing data set. And the fields should all have the same definitions, i.e. char/num and their lengths. How can I do this? Is it possible to "copy" a dataset without its data rows?
(After I have this empty new dataset I'd like to insert just one row with the values I assign.)
02-01-2012 05:43 AM
I found a solution in the manaul for prc sql and the create table statement:
/* create same table but empty */
create table work.calss like sashelp.class;
/* insert new row */
insert into work.class
02-01-2012 06:59 AM
Like works nice, but it does not copy any index information to the target table.
If you want that, you can use PROC APPEND with a non existing BASE table.
This will result that the BASE table will be created, using the metadata from the DATA table.
Proc Append Base=Want Data=Have(obs=0);
02-01-2012 07:22 AM
If using Datastep, you could also try:
if 0 then set have;