相关疑难解决方法(0)

使用SAS宏来管理Windows目录中的文件名列表

我试图修改下面的宏来接受一个宏参数作为dir命令的'location'参数.但是由于嵌套引号问题,我无法正确解析它.使用%str(%')不起作用,也不会出于某种原因引用函数.

当文件路径没有空格(例如C:\ temp\withnospace)时,宏将正常工作,因为不需要中间引号.但是我需要这个宏来处理带空格的文件路径(例如'C:\ temp\with space \').

请帮忙!

%macro get_filenames(location)
   filename pipedir pipe   "dir &location. /b " lrecl=32767;
   data filenames;
     infile pipedir truncover;
     input line $char1000.;
   run;
%mend;

%get_filenames(C:\temp\)              /* works */
%get_filenames('C:\temp\with space')  /* doesnt work */
Run Code Online (Sandbox Code Playgroud)

file-io pipe sas dir sas-macro

7
推荐指数
2
解决办法
4万
查看次数

标签 统计

dir ×1

file-io ×1

pipe ×1

sas ×1

sas-macro ×1