There are many ways to tell if a dataset has any variables. DICTIONARY.TABLES (sashelp.vtable) is one way.
data _null_;
set sashelp.vtable ;
where libname='TESTDATA';
length filename $256;
filename=quote(cats(lowcase(memname),'.csv'));
if nvar then call execute(catx(' ','proc export data=',catx('.',libname,nliteral(memname))
,'dbms=csv out=',filename,'replace;run;'));
else call execute(catx(' ','data _null_;file',filename,';run;'));
run;
... View more