Hi,
I need the code to check whether the directory is empty in sas macro.
This should work
%macro isemptyfolder(folder);
%let filrf=mydir;
%let rc=%sysfunc(filename(filrf, "&folder"));
%let did=%sysfunc(dopen(&filrf));
%let memcount=%sysfunc(dnum(&did));
%let rc=%sysfunc(dclose(&did));
%put 'number of members in folder ' &folder ' = ' &memcount;
%mend isemptyfolder;
Please note this is a Q&A board, not a contract work request system. If you have a question, provide what you have done, show example code using the {i}. If you have access to the command line then doing a filename tmp pipe 'dir c:\test /b'; and using that in a datastep then checking that might work. Not sure what the benefit of checking for an empty directory is though, doesn't really add anything. Do you want to check existence of the folder, or maybe a file you don't want to overwrite?
This should work
%macro isemptyfolder(folder);
%let filrf=mydir;
%let rc=%sysfunc(filename(filrf, "&folder"));
%let did=%sysfunc(dopen(&filrf));
%let memcount=%sysfunc(dnum(&did));
%let rc=%sysfunc(dclose(&did));
%put 'number of members in folder ' &folder ' = ' &memcount;
%mend isemptyfolder;
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: