I would like to rename multiple file extensions from EU to txt using the below code result but I dont get the desired results.
Please note that I am using the UNIX environment.
DATA _NULL_;
X 'rename /EIP/Data/Lev1/Data/FBM/.*EU /EIP/Data/Lev1/Data/FBM/*.txt';
RUN;
A couple of items to fix this ...
First, note that SAS does not require a DATA step in order to run the X command. You only need one line of code.
Second, note that you need a legitimate Unix command. There is no "rename" command in Unix. There is both "mv" and (I believe) "rnm". So get your command working in Unix first, without using SAS. Then it should be straightforward to convert it to a SAS X command.
Also you may want to double check the location of the wildcard character * in the source part of the command
Do you really need to change the extension? What will having the new extention get you that EU cannot provide.
I did not know that you can an EU file using SAS, just tried it and it worked.
Really appreciated... But I would also like to know how to rename multiple files that resides in the same UNIX directory.
I used the below piece of code in windows environment and it worked..
filename ren pipe "dir C:\Users\Desktop\FBM\FILES\NEW\*.EU /b /s";
/*To get the corresponding new file names*/
data ren;
infile ren;
input old : $250.;
new=tranwrd(old,".EU",'.TXT');
run;
/*To rename them all*/
data _null_;
set ren;
rc=rename(old, new, 'file');
put rc;
run;
I think a similar program using SAS RENAME function would work in UNIX just as well as Windows.
I was fiddling with this one line bash script. It does not exectue 'MV' just shows the command with ECHO. It's really the same as your SAS program only different language. I think most folk would do some kind of GREP thing but I'm not good with that.
for file in x*.xml; do echo "Process: $file"; x=`basename $file .xml`; echo "mv $file ${x}.txt"; done;
>for file in x*.xml; do echo "Process: $file"; x=`basename $file .xml`; echo "mv $file ${x}.txt"; done; Process: xmltest.xml mv xmltest.xml xmltest.txt Process: xp1.xml mv xp1.xml xp1.txt Process: xp2.xml mv xp2.xml xp2.txt
Assumes UNIX shell is BASH
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.