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.
*proc options; *run;
options noxwait;
x 'cd C:\documents\study';
x 'ren stdy_details.xlsx Stdy2022.xlsx';
/* end of program */
Koen
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
Thank you. Is it possible using x commands?
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
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
*proc options; *run;
options noxwait;
x 'cd C:\documents\study';
x 'ren stdy_details.xlsx Stdy2022.xlsx';
/* end of program */
Koen
Thank you. It worked for me.
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!
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.