BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
FP12
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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%';

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

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%';
FP12
Obsidian | Level 7

Many thanks,

 

It worked.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1518 views
  • 1 like
  • 3 in conversation