[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sas-l
Subject:    Re: How do drop all tables in a library dynamically
From:       shiling zhang <shiling99 () YAHOO ! COM>
Date:       2003-10-31 15:30:57
[Download RAW message or body]

A couple easy ways may do it.

SAS file utility procedure PROC DATASETS or SAS SQL drop statement.

HTH

data t1 t2 t3 t4 t5 t6 a b c;
run;

proc datasets lib=work mt=data;
  save a;
quit;

data t1 t2 t3 t4 t5 t6 a b c;
run;

proc sql noprint;
  select 'drop table '||trim(memname) into: droplists separated by ';'
  from sashelp.vtable
  where libname='WORK' and memname ne 'A'
  ;
  &droplists
  ;
quit;


rune@fastlane.no (Rune Runnestoe) wrote in message \
news:<24410121.0310300750.39f045d1@posting.google.com>...
> Hello,
> 
> The issue is to drop all tables in a sas library dynamically, without
> having to hard-code the names of all the tables with "drop table
> &bibl..my_table1;"
> 
> For example:
> 
> libname my_lib        "D:\my_catalog";
> %let bibl=my_lib;
> 
> proc sql;
> create table &bibl..my_table1 as
> select *
> from sashelp.class;
> create table &bibl..my_table2 as
> select *
> from sashelp.company;
> create table &bibl..my_table3 as
> select *
> from sashelp.company;
> quit;
> 
> Say that I do know what the name of the library is, but I have no idea
> of what the names of the tables are, or how many tables there are.
> Do you have a proposal for the code to drop the three tables
> dynamically ?
> Say that you do know the name of "my_table3" and you want to write the
> code in a way that preserves this table. How do you do that ?
> 
> Can this coding be done in the datastep as well as by means of the
> proc sql ?
> If so, can you show me how ?
> 
> Regards
> Rune Runnestoe


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic