BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ronein
Meteorite | Level 14

Hello

I want to delete data sets that appear in column  "memname"  in data set tables_tbl.

What is the way to do it please?

The only step that I know to do it to create data set that included the names of the data sets that I want to delete.

Please note that I know to delete each data set manually using PROC DELETE   but the question is how to delete the data sets in one step 


Data ttt1;
X=10;
Run;

Data ttt2;
X=15;
Run;

Data WWW1;
Z=10;
Run;

PROC SQL;
  CREATE TABLE tables_tbl AS
  SELECT *
  FROM dictionary.tables
  WHERE libname = 'WORK' and memname like '%TTT%'
;
QUIT;
1 ACCEPTED SOLUTION
8 REPLIES 8
PeterClemmensen
Tourmaline | Level 20

From your own example, do this

 

Data ttt1;
X=10;
Run;

Data ttt2;
X=15;
Run;

Data WWW1;
Z=10;
Run;

PROC SQL noprint;
   select memname
   into :t separated by ' '
   from dictionary.tables
   WHERE libname = 'WORK' and memname like '%TTT%'
   ;
quit;

%put &t.;

proc datasets lib = work nolist;
   delete &t.;
quit;
Ronein
Meteorite | Level 14
As I said the names of data sets can be with different names so this solution is not as I wish
PeterClemmensen
Tourmaline | Level 20
Your question is how to delete all data sets in tables_tbl in one step. That is what my code does.

Please be more specific about what data sets are to be deleted? Do they appear in a table?
Ronein
Meteorite | Level 14

Please see again the list of  data sets that I want to delete

Data ttt1;
X=10;
Run;
Data ttt2;
X=15;
Run;
Data WWW1;
Z=10;
Run;

data revenue_tbl;
input ID revenue;
cards;
1 100
2 200
;
Run;


PROC SQL;
  CREATE TABLE tables_tbl AS
  SELECT *
  FROM dictionary.tables
  WHERE libname = 'WORK' and  (memname like '%TTT%' OR memname='REVENUE_TBL'  OR  memname='WWW1')
;
QUIT;
PeterClemmensen
Tourmaline | Level 20
How is this any different from your initial post? Once again, the data set names can be different than what you post, correct?
Ronein
Meteorite | Level 14
The task is to tell sas to delete all data sets appear in column "memname" in data set tables_tbl.
No need to say what to delete
need to say to delete all
PeterClemmensen
Tourmaline | Level 20

But, when you create the tables_tbl data set, you specify the rules manually for what data sets are to be deleted?

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 595 views
  • 2 likes
  • 3 in conversation