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
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;
The code you showed should work fine.
So what code did you try that did NOT work?
@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.
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;
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: