An Idea Exchange for SAS software and services

Comments
by Super User
on ‎05-23-2014 06:44 AM

Mmm, suppose it wouldn't hurt, however not sure of the value when you could do something simple like:

proc sql;

  create table WORK.CARS as

  select  *

  from    SASHELP.CARS

  where   0=1;

quit;

If necessary just pop that in a macro for multiple use etc.

If you want to create an empty table based on metadata then that's a slightly different task.  It can be achieved in many different ways, the below code generator being one.

data _null_;

  set sashelp.vcolumn (where=(libname="SASHELP" and memname="CARS")) end=last;

  attrib lne format=$2000.;

  if type="num" then lne=" num";

  else lne=" char("||strip(put(length,best.))||")";

  if _n_=1 then call execute('proc sql;

                                create table WORK.CARS

                                (

                                  '||strip(name)||' '||strip(lne)||' label="'||strip(label)||'"');

  else call execute(','||strip(name)||' '||strip(lne)||' label="'||strip(label)||'"');

  if last then call execute(');quit;');

run;

by Super Contributor
on ‎05-23-2014 07:32 AM

Support the idea

Shouldn't need a workaround for a common SQL action.  Should not be difficult to implement.

Richard

by Super User
on ‎09-01-2014 05:44 AM

Yes, the idea of truncations is to keep ALL meta data intact, just remove physical data.

Your example just gives column type, length, name and label. So what about indexes, constraints, keys etc? Those will be kept using the PROC APPEND-approach. But still, both are just workarounds.

by Respected Advisor
on ‎09-01-2014 08:32 PM

If you don't have indexes or constraints to worry about, then simply create a new table LIKE the old one:

Proc sql;

create table a like a;

quit;

PG

Idea Statuses
Top Liked Authors