BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASuserlot
Barite | Level 11

Can we use the SAS to rename the file name that already existed in the folders using the  system commands? if so can you please tell me how to achieve this:

Folder: "c\documents\study

Old filename: stdy_details.xlsx

New Name: Stdy2022.xlsx

I want to rename the old file with new name.   If possible both ways using base SAS and X command .Thanks for your time. 

1 ACCEPTED SOLUTION

Accepted Solutions
sbxkoenk
SAS Super FREQ
*proc options; *run;

options noxwait;
x 'cd C:\documents\study';
x 'ren stdy_details.xlsx Stdy2022.xlsx';
/* end of program */

Koen

View solution in original post

6 REPLIES 6
sbxkoenk
SAS Super FREQ

Hello,

 

With the SAS RENAME function , you can also rename external files !

 

See here :

SAS® 9.4 and SAS® Viya® 3.5 Programming Documentation | SAS 9.4 / Viya 3.5
Functions and CALL Routines
RENAME Function
Renames a member of a SAS library, an entry in a SAS catalog, an external file, or a directory.
https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p14axci3mo3egan1okbcydvbt43...

 

Koen

SASuserlot
Barite | Level 11

Thank you. Is it possible using x commands?

sbxkoenk
SAS Super FREQ

Of course, with X-command or CALL SYSTEM.

Unless your SAS administrator has disabled that functionality in the configuration file.

 

option XCMD enables the X command in SAS.

option noXCMD disables the X command in SAS.

 

Koen

SASuserlot
Barite | Level 11

Thank you, if possible can you please give me an example how to rename  a file using x command using SAS. I am not that great with he x commands in SAS. in the following scenario

 

Folder: "c\documents\study

Old filename: stdy_details.xlsx

New Name: Stdy2022.xlsx

sbxkoenk
SAS Super FREQ
*proc options; *run;

options noxwait;
x 'cd C:\documents\study';
x 'ren stdy_details.xlsx Stdy2022.xlsx';
/* end of program */

Koen

SASuserlot
Barite | Level 11

Thank you. It worked for me.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 6 replies
  • 1479 views
  • 3 likes
  • 2 in conversation