BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Liquid
Calcite | Level 5

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

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;

View solution in original post

5 REPLIES 5
jakarman
Barite | Level 11

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.

---->-- ja karman --<-----
Liquid
Calcite | Level 5

Unfortunately we don't have rights to change some of the parent directories.

jakarman
Barite | Level 11

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"'

---->-- ja karman --<-----
Patrick
Opal | Level 21

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;

Kurt_Bremser
Super User

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)

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2364 views
  • 3 likes
  • 4 in conversation