Skip to content
Advertisement

Apparent invocation of macro not resolved in sas filename pipe

I am using the following SAS code to find all files and their sizes under the directory &directory.

JavaScript

Though the output data tmp is what I want, the code will give me warning.

WARNING: Apparent invocation of macro S not resolved.

I have tried adding an extra ‘%’ before ‘%’, i.e.

JavaScript

but it doesn’t work.

How can I get rid of the warning? Thank you.


I have also tried %str and %nrstr,

JavaScript

None of them solved the problem.

Advertisement

Answer

The macro processor will look for macro triggers & and % inside of strings enclosed in double quotes, but not those enclosed in single quotes. You can use the quote() function to enclose the string in single quotes.

JavaScript

Or you can just use SAS code and avoid letting the macro processor get involved.

Instead of making a FILENAME statement you could use a datastep to call the FILENAME() function.

JavaScript

Or you could not create a fileref at all and instead just use the FILEVAR= option on the INFILE statement to pass in the command.

JavaScript

Note: reversing the order of the size and path in the printf string will avoid issues parsing the results when there are filenames that have embedded spaces.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement