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;
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!
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.
Ready to level-up your skills? Choose your own adventure.