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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.