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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.