Hi all,
I am trying to use the handy rename function (http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a003122440.htm)s in to change the name of external files.
This works:
DATA _NULL_;
rc=rename("c:\testsas\file", "c:\testsas\file_renamed", 'file');
PUT rc;
RUN;
But this does not work:
DATA _NULL_;
rc=rename("c:\test sas\file", "c:\test sas\file_renamed", 'file');
PUT rc;
RUN;
How can I get it to work when there are spaces in the directory/file?
Below code works for me with SAS9.4 under Win7. Are you 100% sure that the file you want to rename exists under your path?
DATA _NULL_;
rc=rename("C:\test\name with blank\have.txt", "C:\test\name with blank\have_renamed.txt", 'file');
PUT rc;
RUN;
Is avoiding spaces in file and/or directory names an answer? I have seen more issues on this with SAS. the problem is you need ^ at the oslevel arround the file/directory name. This "often ha a different meaning in Sas or in thé she'll in between. That is becoming a fight on to the ' and ". Sometimes disappearing magically.
Unfortunately we don't have rights to change some of the parent directories.
Did you try; embedding in single quotes as indication of a sas string and inner embedded with double quotes as of Windows allowing spaces?
You are seeing the ' and " close after each other.
'"Test folfder/file bsme"'
Below code works for me with SAS9.4 under Win7. Are you 100% sure that the file you want to rename exists under your path?
DATA _NULL_;
rc=rename("C:\test\name with blank\have.txt", "C:\test\name with blank\have_renamed.txt", 'file');
PUT rc;
RUN;
Enclose the names in additional single quotes:
'"c:\testsas\file"', '"c:\testsas\file_renamed"'
and put a big sign up at the company's door:
DO NOT USE BLANKS IN FILENAMES
(all employees repeat 100 times during morning meditation)
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.