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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.