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
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.