windows下使用SAS和mkdir创建目录结构 [英] Using SAS and mkdir to create a directory structure in windows

查看:31
本文介绍了windows下使用SAS和mkdir创建目录结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 SAS 中在 Windows 中创建一个目录结构.最好使用允许我指定 UNC 命名约定的方法,例如:

I want to create a directory structure in Windows from within SAS. Preferably using a method that will allow me to specify a UNC naming convention such as:

\computernamedownloadsxyz

我在网上看到了许多使用 DOS mkdir 命令的 SAS 示例,这些命令通过 %sysexec()x 命令调用.mkdir 命令的好处是,如果它们也不存在,它将创建任何中间文件夹.我从提示符成功测试了以下命令,它的行为符合预期(引用似乎无关紧要,因为我的路径名中没有空格):

I have seen many examples for SAS on the web using the DOS mkdir command called via %sysexec() or the xcommand. The nice thing about the mkdir command is that it will create any intermediate folders if they also don't exist. I successfully tested the below commands from the prompt and it behaved as expected (quoting does not seem to matter as I have no spaces in my path names):

mkdir \computernamedownloadsxyz
mkdir d:y
mkdir d:yy
mkdir "d:z"
mkdir "d:zz"
mkdir \computernamedownloadszzz
mkdir "\computernamedownloadszzz"

以下从 SAS 运行良好:

The following run fine from SAS:

x mkdir d:x;
x 'mkdir d:y';
x 'mkdir "d:z"';
x mkdir \computernamedownloadsx;
x 'mkdir \computernamedownloadsy';

但是从 SAS 运行时这些不起作用,例如:

But these do not work when run from SAS,eg:

x mkdir d:xx;
x 'mkdir d:yy';
x 'mkdir "d:zz"';
x mkdir \computernamedownloadsxyz ;
x 'mkdir "\computernamedownloadsz"';

** OR **;

%sysexec mkdir "\computernamedownloadsxyz ";

** OR **;

filename mkdir pipe "mkdir \computernamedownloadsxyz";
data _null_;
  input mkdir;
  put infile;
run;

它不起作用.不仅如此,即使我指定了 options xwait,窗口也会立即关闭,因此没有机会看到任何错误消息.我已经尝试了所有使用 UNC 路径和驱动器号路径的方法,即.D:downloadsxyz.

It does not work. Not only this but the window closes immediately even though I have options xwait specified so there is no opportunity to see any ERROR messages. I have tried all methods with both the UNC path and a drive letter path, ie. D:downloadsxyz.

如果我查看操作系统返回的错误消息:

If I look at the error messages being returned by the OS:

%put %sysfunc(sysrc()) %sysfunc(sysmsg());

我得到以下信息:

-20006 WARNING: Physical file does not exist, d:downloadsxxx.

查看 mkdir 命令的文档,它似乎只支持在启用命令扩展"时创建中间文件夹.这可以通过将 /E:ON 添加到 cmd.exe 来实现.我尝试更改要使用的代码:

Looking at the documentation for the mkdir command it appears that it only supports creating intermediate folders when 'command extensions' are enabled. This can be achieved with adding the /E:ON to cmd.exe. I've tried changing my code to use:

cmd.exe /c /E:ON mkdir "\computernamedownloadsxyz"

仍然没有运气!

谁能告诉我,为什么除了我之外,互联网上的其他人似乎都能够在 SAS 内部完成这项工作?同样,它在 DOS 提示符下工作正常 - 只是在 SAS 中不行.

Can anyone tell me why everyone else on the internet seems to be able to get this working from within SAS except for me? Again, it works fine from a DOS prompt - just not from within SAS.

我更喜欢专门解决这个问题的答案(我知道还有其他使用多个步骤或 dcreate() 的解决方案.

I'd prefer an answer that specifically address this issue (I know there are other solutions that use multiple steps or dcreate()).

我正在运行 WinXP 32 位、SAS 9.3 TS1M2.谢谢.

I'm running WinXP 32Bit, SAS 9.3 TS1M2. Thanks.

推荐答案

您需要使用 mkdir 选项 -p 将创建所有子文件夹

You need to use the mkdir option -p which will create all the sub folders

x mkdir -p "c:
ewdirectorylevel 1level 2";

这篇关于windows下使用SAS和mkdir创建目录结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆