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;
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!
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.