Hello,
I have a dataset name filelisting. One of its variable is unixcommand and the first observation look like below
sed -i 's/"prod@test.net"//g' /.../sasmacro/email.sas
if I execute the above unix command directrly on the terminal via winscp, its works very well and it erase the sting "prod@test.net" from email.sas
How do we passed this unix command using
data _null_;
set filelisting;
call execute('something');
run;
CALL EXECUTE() is for submitting SAS code.
To run an operating system command (so if your SAS session is running on UNIX then it could be a UNXI command) you can use a PIPE.
To use an existing variable as the source of the filename (the string that will the command run in the pipe) use the FILEVAR= option of the INFILE statement. To see if the command tries to send back any messages just read the lines it writes.
So if variable UNIXCOMMAND in the dataset FILELISTING has the commands to run then you want something like this:
data _null_;
set filelisting;
infile unix pipe filevar=unixcommand end=eof;
do while (not eof);
input;
put _infile_;
end;
run;
CALL EXECUTE() is for submitting SAS code.
To run an operating system command (so if your SAS session is running on UNIX then it could be a UNXI command) you can use a PIPE.
To use an existing variable as the source of the filename (the string that will the command run in the pipe) use the FILEVAR= option of the INFILE statement. To see if the command tries to send back any messages just read the lines it writes.
So if variable UNIXCOMMAND in the dataset FILELISTING has the commands to run then you want something like this:
data _null_;
set filelisting;
infile unix pipe filevar=unixcommand end=eof;
do while (not eof);
input;
put _infile_;
end;
run;
Thank you very much
Left off the DO of the DO WHILE statement. I will correct in the original post.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.