包含两个宏变量的 SAS 宏变量未解析

SAS macro variable containing two macro variables is not resolved

我有两个宏变量,路径和文件,它们都包含特殊字符。我对两者都使用 %str 。然后将它们组合成另一个宏变量,direct。

当我在文件名管道语句中使用 &direct 时,它没有被解析。

谁能告诉我哪里出了问题?

我试过双引号或 %sysfunc(cats())。也不行。

代码为:

%let path=%str(B:\Enrollment Report\Fall 18F Enroll- MASTER\);
%let file=%str(18F Enroll as *.xlsx);
%let direct=%sysfunc(cats(&path, &file));

%put &direct;

filename dirlist pipe 'dir "&direct" /b';



NOTE: The infile DIRLIST is:
      Unnamed Pipe Access Device,
      PROCESS=dir "&direct" /b,RECFM=V,LRECL=200

单引号内的宏触发器未解析。一种简单的方法是改用双引号字符,请记住将任何嵌入的双引号字符加倍。

请注意,无需在宏代码中使用 CATS()。或者将 %STR() 宏引号添加到不需要引号的值。

%let path=B:\Enrollment Report\Fall 18F Enroll- MASTER;
%let file=18F Enroll as *.xlsx;
%let direct=&path\&file;
filename dirlist pipe "dir ""&direct"" /b";