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

Hello

 

I currently set the value of a file name as %let export_db="E:\data\2020 21\Q2\inst5555.xlsx";

 

I can set the institution variable as %let export_db="E:\data\2020 21\Q2\inst_&dqInst..xlsx" (where dqinst is set separately) and it works.  But I have many different institutions at various periods in their data and I would like to create variables for fiscal year and quarter so I don't have to change all the time but how do I put it together?   For example, below doesn't work:

"E:\data\"||&fiscal||"\"||&qtr||"\"||"DAD DQ_&DQInst..xlsx"

 

Any and all help greatly appreciated. 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
"E:\data\&fiscal.\&qtr.\DAD DQ_&DQInst..xlsx"

Expand on your original solution - no need to concatenate manually.

View solution in original post

5 REPLIES 5
Reeza
Super User
"E:\data\&fiscal.\&qtr.\DAD DQ_&DQInst..xlsx"

Expand on your original solution - no need to concatenate manually.
PaigeMiller
Diamond | Level 26

You don't need || to concatenate macro variables and text. Try this:

 

"E:\data\&fiscal\&qtr\DAD DQ_&DQInst..xlsx"

 

--
Paige Miller
shellp55
Quartz | Level 8

Thank you for your responses.  Previously, when I wasn't "building from variables", the Excel file would just open up with the name I had created i.e. DAD_DQ_Inst5555.xlsx.  But now that I am building the file name from variables I get an error message that "physical file does not exist".  Why would that be and how do I correct it?   Thanks.

Reeza
Super User
Double check how the full file path is resolving. I'm guessing it's adding some additional spaces somewhere so the file path doesn't end up matching exactly.

Run the code with the MPRINT option on and show us the actual error if you cannot resolve it.
shellp55
Quartz | Level 8

You are correct, Reeza, I was missing a subfolder in the name.  Now it works and all is well.  Thanks very much.

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
  • 5 replies
  • 1443 views
  • 2 likes
  • 3 in conversation