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

Hello

What is the way (code) to delete all data sets that start with name "ABC"  if they contain number of rows=0?

Let's say that each day there are many data sets start with name ABC.

Some of the data sets have 0 rows and we need to delete them.

For example:

ABC20191201  ,ABC20191202 ,ABC20191203,ABC201912014,.....and so on.

Is there a clever way to tell SAS to delete each data set that contain 0 rows (from series of data sets names ABC..)?

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Hi @Ronein  Here is a demo 

 


/*0 rows samples*/

data ABC20191201 ABC20191202 ABC20191203 ABC201912014;
stop;
set sashelp.class;
run;
/*a sample that is not 0 rows*/
data ABC2345;
set sashelp.class;
run;

data _null_;
set sashelp.vtable(keep=libname memname nobs);
where libname='WORK' and memname=:'ABC';
if nobs=0;
call execute(cats('proc delete data=',memname,';run;'));
run;

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20

Hi @Ronein  Here is a demo 

 


/*0 rows samples*/

data ABC20191201 ABC20191202 ABC20191203 ABC201912014;
stop;
set sashelp.class;
run;
/*a sample that is not 0 rows*/
data ABC2345;
set sashelp.class;
run;

data _null_;
set sashelp.vtable(keep=libname memname nobs);
where libname='WORK' and memname=:'ABC';
if nobs=0;
call execute(cats('proc delete data=',memname,';run;'));
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 1503 views
  • 1 like
  • 2 in conversation