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..)?
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;
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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: