using quotes in sas macro filename pipe

╄→尐↘猪︶ㄣ 提交于 2019-12-01 12:22:10

问题


I am using the following Macro that uses filename pipe. But get an error saying invalid option name "dir", etc. I suspect it could be due to the quotes while defining filename and pipe. I guess it recognizes it as an option. I tried to remove the quote, removing %bquote and having just the double quote, but still keep getting the errors.

I am using Windows, but will also be running it remotely on Linux. Any thoughts would be deeply appreciated.

%macro setprogvar(dateval);
  %global date;

  %let date=&dateval;

  %put &date;
  %put &dateval;

  %let filepath = %bquote("C:\Research\SASDataSets\bulk all data &date");

  filename CDR_Bulk pipe "dir &filepath /a:-d-h-s /b /s";

%mend setprogvar;

%setprogvar(20100331);

***LOG************
1      filename CDR_Bulk pipe "dir &filepath /a:-d-h-s /b /s";
                           ---
                           23
ERROR 23-2: Invalid option name dir.

1   !  filename CDR_Bulk pipe "dir &filepath /a:-d-h-s /b /s";
                                          -
                                          23
ERROR 23-2: Invalid option name a.

回答1:


The filepath Macro variable needs wrapping in double-quotes as it contains spaces. But as your string is double-quoted, you need double-double-quotes...

filename CDR_Bulk pipe "dir ""&filepath"" /a:-d-h-s /b /s";



回答2:


Try changing %bquote in your macro to %str().

%Str() works during macro compile time, and should mask the double quote marks.

HTH



来源:https://stackoverflow.com/questions/25107863/using-quotes-in-sas-macro-filename-pipe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!