08-22-2014 12:11 PM
How would one export to a directory that has a single quote in it's name? Example: Say I had a file directory that was I:\projects\Brandon's Files. (i realize how bad it is to create a directory with a single quote, but that is not important to the question).... Anyways, when I run
proc export data=testme outfile="I:\projects\Brandon's files\dontwork.xls" replace;
I get the error
ERROR: Option "s" is not known for LIBNAME
133 data _EXCEXP.'testme'n;
WARNING: End-of-file encountered in string.
It looks like the system doesn't recognize that the single quote is part of the name, and not the start of a string literal....
I tried defining the string in a filename statement like so.
filename mydata "I:\projects\Brandon's Files\dontwork.xls" and then changing the project export too...
proc export data=testme outfile=mydata replace;
However I get the exact same error. Seems like the system cannot recognize that the single quote is actually part of the file reference location, and not the start of an actual string....
The ONLY Way i've been able to 'solve' this is by adding a secondary quote into the file path WHENEVER a first quote is found.. AKA changing my file path location too..
proc export data=testme outfile="I:\projects\Brandon''s files\dontwork.xls" replace;
However I frankly don't feel like this is a valid solution, as I would then basically have to write code toi check for single quotes in ANY file name, or ANY path directory, any time I write or read data from them... Is there a way around this?
Thanks very much!
08-22-2014 01:24 PM
Did you try adding another layer of quotes so that SAS can pass a quoted filename to the operating system?
You might need to add the DBMS= option since SAS might get confused about what export engine you want.
proc export data=testme replace
08-22-2014 01:56 PM
As long it are directory names. Isolate them with a filename at an initial part code.
eg: - filename filebrn "I:\projects\Brandon''s files" ;
than use: - filebrn(dontwork.xls) - as your coding.
It will make your code also better portable to other environments.
08-23-2014 10:37 AM
Try another Engine .
proc export data=sashelp.class outfile="c:\temp\Brandon's files\dontwork.xls" dbms=xls replace;
401 proc export data=sashelp.class outfile="c:\temp\Brandon's files\dontwork.xls" dbms=xls replace;
NOTE: The export data set has 19 observations and 5 variables.
NOTE: "c:\temp\Brandon's files\dontwork.xls" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
real time 0.10 seconds
cpu time 0.01 seconds