在 sas 宏文件名管道中使用引号 [英] using quotes in sas macro filename pipe
问题描述
我正在使用以下使用文件名管道的宏.但是得到一个错误,说无效的选项名称dir"等.我怀疑这可能是由于定义文件名和管道时的引号引起的.我猜它认为它是一种选择.我试图删除引号,删除 %bquote 并只有双引号,但仍然不断收到错误.
我使用的是 Windows,但也将在 Linux 上远程运行它.任何想法将不胜感激.
%macro setprogvar(dateval);%全球日期;%let date=&dateval;%put &日期;%put &日期;%let filepath = %bquote("C:ResearchSASDataSetsulk all data &date");文件名 CDR_Bulk 管道 "dir &filepath/a:-d-h-s/b/s";%修正setprogvar;%setprogvar(20100331);***日志************1 文件名 CDR_Bulk 管道 "dir &filepath/a:-d-h-s/b/s";---23错误 23-2:无效的选项名称目录.1!文件名 CDR_Bulk 管道 "dir &filepath/a:-d-h-s/b/s";-23错误 23-2:无效的选项名称
文件路径宏变量需要用双引号括起来,因为它包含空格.但是由于你的字符串是双引号,你需要双双引号......
<上一页>文件名 CDR_Bulk 管道 "dir ""&filepath""/a:-d-h-s/b/s";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:ResearchSASDataSetsulk 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.
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";
这篇关于在 sas 宏文件名管道中使用引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!