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

I am just not getting something that should be obvious, so forgive my ignorance.

I have looked:

https://communities.sas.com/t5/SAS-Programming/Making-macro-variables-resolve-with-filename-pipe-com...

https://communities.sas.com/t5/General-SAS-Programming/SAS-Macro-using-doubles-quotes-filename-pipe/...

https://communities.sas.com/t5/SAS-Procedures/macro-variable-resolution-in-pipe/td-p/112978

https://communities.sas.com/t5/General-SAS-Programming/Macro-variable-in-filename-statement/td-p/343...

One would think that after that, I would have the solution, but no matter which combination I try, I'm not getting the right result:

So I want to replace this:

FILENAME _FList PIPE 'dir "c:\Users\...\Study-data\Posts from 20* to 2020-*.XLSX" /b ';

with this:

%LET DataDir=c:\Users\...\Study-data\;
FILENAME _FList1 PIPE 'dir &DataDir.Posts from 20* to 2020-*.XLSX /b';

But no matter how I try to quote it, I am missing what I am sure is a pretty obvious solution.

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
yabwon
Onyx | Level 15
%LET DataDir=c:\Users\...\Study-data\;
FILENAME _FList1 PIPE "dir ""&DataDir.Posts from 20* to 2020-*.XLSX"" /b";
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

This is probably macro mistake #1 for macro newbies 🙂 Been there, done that 😉

 

Whenever you want macro variables to resolve in a string, use double quotes instead of single quotes.

yabwon
Onyx | Level 15
%LET DataDir=c:\Users\...\Study-data\;
FILENAME _FList1 PIPE "dir ""&DataDir.Posts from 20* to 2020-*.XLSX"" /b";
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1935 views
  • 1 like
  • 3 in conversation