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
Amethyst | Level 16
%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
Amethyst | Level 16
%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



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
  • 2 replies
  • 2895 views
  • 1 like
  • 3 in conversation