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

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
Onyx | Level 15
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
Onyx | Level 15

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
Onyx | Level 15
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?

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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