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

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;

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