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

Hello,

 

I am trying to export to a file that contains an apostrophe using the following:

proc export data=datasas2
outfile="C:\user\filepath\John's Folder\file.xlsx"
dbms=excel replace;
run;

I've tried to place the file path in a macro using %let with %quote, but I'm sure that I'm not using this correctly.

Please help.

 

Many thanks,

 

JFuchsia

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Just put the whole path you used in the example code into the macro variable. 

There is no need for macro quoting when you have real quoting.

%let filename="C:\user\filepath\John's Folder\file.xlsx";

Then just use the macro variable where you need a quoted filename.

proc export data=datasas2
  outfile=&filename
  dbms=xlsx replace
;
run;

 

 

View solution in original post

5 REPLIES 5
JFuchsia
Obsidian | Level 7
PS. I can't change the file path due to some pretty strict IT constraints. Thanks.
Tom
Super User Tom
Super User

The code you showed should work fine.

 

So what code did you try that did NOT work?

ballardw
Super User

@JFuchsia wrote:
PS. I can't change the file path due to some pretty strict IT constraints. Thanks.

"Strict IT constraints" and apostrophe in path points to a pretty not-tech savvy IT.  Spaces in file paths are enough of a challenge (looking at the path might not tell the difference between one or two spaces easily) but special characters like comma * dash single quote or double quote are just asking for all sorts of stupid problems.

 

One stupid problem involving quotes is the ASCII ' or " character versus "smart quotes" which have a curly appearance and often not noticed by folks. If your actual path uses the curly quotes you don't have the correct character on your keyboard.

Kurt_Bremser
Super User

@ballardw wrote:

@JFuchsia wrote:
PS. I can't change the file path due to some pretty strict IT constraints. Thanks.

"Strict IT constraints" and apostrophe in path points to a pretty not-tech savvy IT. 


Nicely said. I would have called them "brain-amputated idiots".

Tom
Super User Tom
Super User

Just put the whole path you used in the example code into the macro variable. 

There is no need for macro quoting when you have real quoting.

%let filename="C:\user\filepath\John's Folder\file.xlsx";

Then just use the macro variable where you need a quoted filename.

proc export data=datasas2
  outfile=&filename
  dbms=xlsx replace
;
run;

 

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 924 views
  • 0 likes
  • 4 in conversation