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;

 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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
  • 401 views
  • 0 likes
  • 2 in conversation