Hi,
Running below macro on EG 4.2....What command should i use instead of mkdir.
%macro chk_dir(dir=);
%local rc fileref;
%let rc = %sysfunc(filename(fileref,&dir));
%if %sysfunc(fexist(&fileref)) %then
%put NOTE: The directory "&dir" exists;
%else
%do;
%sysexec md &dir;
%put %sysfunc(sysmsg()) The directory has been created.;
%end;
%let rc=%sysfunc(filename(fileref));
%mend chk_dir;
%chk_dir(dir=C:\test);
Thanks,
rk.
Not sure what your question is. Are you looking for a SAS function? The following post suggests using dcreate
Are you saying that the mkdir command is not working for you?
%macro chk_dir(dir=);
%local rc fileref;
%let rc = %sysfunc(filename(fileref,&dir));
%if %sysfunc(fexist(&fileref)) %then
%put NOTE: The directory "&dir" exists;
%else
%do;
%sysexec mkdir "&dir" ; <======== What happens if you use this code instead?
%put %sysfunc(sysmsg()) The directory has been created.;
%end;
%let rc=%sysfunc(filename(fileref));
%mend chk_dir;
Hi Robby;
Same issue with md and mkdir.
%chk_dir(dir=c:\test);
ERROR: Shell escape is not valid in this SAS session.
Thanks,
rk;
Did you try dcreate?
art,
It worked with dcreate.
Thanks a lot....but want to check,why it is not accepting spaces with mkdir.
Regards,
rk.
You might also want to take a look at: http://support.sas.com/kb/15/179.html
By default the EG workspace server is started with the -noxcmd option, meaning you cannot exit to the O/S to execute arbitrary code. This is by design as a security feature.
If your server is a Windows server, you can make low level calls to the O/S via SASCBTBL. See http://www.devenezia.com/downloads/sas/sascbtbl/. AFAIK EG still allows this workaround to the -noxcmd option.
But yeah, IMO best practice is to use SAS code where possible. This way your code is usually portable across O/S's. So if dcreate works for you that would be the best solution.
HTH,
Scott
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.