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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 387 views
  • 0 likes
  • 4 in conversation