- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
*proc options; *run;
options noxwait;
x 'cd C:\documents\study';
x 'ren stdy_details.xlsx Stdy2022.xlsx';
/* end of program */
Koen
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. Is it possible using x commands?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
*proc options; *run;
options noxwait;
x 'cd C:\documents\study';
x 'ren stdy_details.xlsx Stdy2022.xlsx';
/* end of program */
Koen
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. It worked for me.