I would like to check if a windows directory is empty, if so delete it otherwise end.
Is this possible via SAS Base 9.4 and Windows 7
Its possible, and there are a few options. You could stream in a dir pipe (not tested):
filename tmp pipe 'dir "c:\temp" /b';
data _null_;
infile tmp dlm="¬";
input buffer $;
if buffer="your dir" then found=1;
run;
Or you could do it in a macro:
http://www.sascommunity.org/wiki/Tips:Check_if_a_directory_exists
And to delete:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245893.htm
The question is, why. I generally try to avoid doing OS manipulations through SAS, especially through macro, as an unresolved macro, or problem url could lead to all kinds of problems. Most of the time I find there are systematci problems if your having to do this anyways.
Its possible, and there are a few options. You could stream in a dir pipe (not tested):
filename tmp pipe 'dir "c:\temp" /b';
data _null_;
infile tmp dlm="¬";
input buffer $;
if buffer="your dir" then found=1;
run;
Or you could do it in a macro:
http://www.sascommunity.org/wiki/Tips:Check_if_a_directory_exists
And to delete:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245893.htm
The question is, why. I generally try to avoid doing OS manipulations through SAS, especially through macro, as an unresolved macro, or problem url could lead to all kinds of problems. Most of the time I find there are systematci problems if your having to do this anyways.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.