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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.