BookmarkSubscribeRSS Feed
alepage
Barite | Level 11

Here's an example how to rename a file in Unix via a pipe command.

 

 

filename oscmd pipe "mv ""&file_path./&xmlFile."" ""&file_path./&xmlFile2."" 2>&1";

data _null_;
infile oscmd;
input;
put _infile_;
run;

 

 

 

But how do we execute the following perl command:

perl -pe 's/[^çêèàûéîôâÇÀÛÔÉÇÈÊ"@-_<>’[:ascii:][:alnum:][:space:][:punct:]]+//g' </&Path1/Virage Survey.xml> &Path1./VirageSurvey.xml

 

 

 

1 REPLY 1
Tom
Super User Tom
Super User

Why would it work any differently????

 

Just be careful with the quotes.  Both SAS and unix shells are picky about making sure the quotes a balanced and appropriate.  The QUOTE() function can help.

Note you don't need to use a FILENAME statement.  You can include the command in the INFILE statement directly instead.

%let path1=/some/folder/name ;
%let cmd=perl -pe 's/[^çêèàûéîôâÇÀÛÔÉÇÈÊ"@-_<>’[:ascii:][:alnum:][:space:][:punct:]]+//g' </&Path1/Virage Survey.xml >&Path1./VirageSurvey.xml; data _null_;
infile %sysfunc(quote(&cmd)) pipe;
input;
put _infile_;
run;

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 533 views
  • 0 likes
  • 2 in conversation