Hi,
I am creating a file extraction macro based on this
data &output_table. (where=(filename like &filenames.));
In the definition of my macro I have the two variables:
-output_table
-filenames
I call my macro in another part by defining output_table, and filenames like:
filenames = "File_52%Q&period_quarter.%.xls%"
where period_quarter is another macrovariable equal to 1 in my case
When I run it I have this warning, despite it is running well and give me good results:
WARNING: Apparent invocation of macro Q1 not resolved.
Surely because it is using the % character as a macro calling.
What I don't understand is that for the second % and third %, I don't have the warning.
Do you know what happens here?
Thanks
The percent at the end of the string has nothing following, so it can't be a macro call. The secoind percent is follwed immediately by a dot (invalid in SAS names), so it also can't be a macro call. But the first percent is followed by something that could be a macro name, and that causes your problem.
Restructure your statement to mask the macro triggers:
filenames = 'File_52%Q'!!"&period_quarter"!!'%.xls%';
The percent at the end of the string has nothing following, so it can't be a macro call. The secoind percent is follwed immediately by a dot (invalid in SAS names), so it also can't be a macro call. But the first percent is followed by something that could be a macro name, and that causes your problem.
Restructure your statement to mask the macro triggers:
filenames = 'File_52%Q'!!"&period_quarter"!!'%.xls%';
Many thanks,
It worked.
BTW one of the reasons why such special characters have no place in data file names, along with blanks.
Post what you are trying to do. Supply test data in the form of a datastep. Its highly likely there are better methods than what you are doing here. It looks like your using % as a wildcard for instance, you would be better off fixing it down to something more like scan(file,2,".") in ("XLS","XLSX"); Although do note you may have to handle these things differntly. Further info is needed for more help.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.