0
votes

I have two macro variables, path and file, both of them contains special characters. I use %str for both. Then combine them as another macro variable, direct.

when I use &direct in filename pipe statement, it is not resolved.

Can anyone tell me what it is wrong?

I have tried double quote or %sysfunc(cats()). not work either.

code as:

%let path=%str(B:\Enrollment Report\Fall 18\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
1
Macro triggers, & and %, are not evaluated inside of strings that use single quotes on the outside.Tom

1 Answers

2
votes

Macro triggers are not resolved inside of single quotes. One easy way is to use double quote characters instead, remember to double any embedded double quote characters.

Note there is no need to use CATS() in macro code. Or add %STR() macro quoting to values that don't need quoting.

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