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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 87 views
  • 0 likes
  • 2 in conversation