DATA Step, Macro, Functions and more

Executing .exe file thru SAS

Accepted Solution Solved
Reply
Contributor
Posts: 33
Accepted Solution

Executing .exe file thru SAS

1) How to call .exe file in SAS 9.4? OR SAS Enterprise Guide?

 


Accepted Solutions
Solution
‎02-13-2017 08:07 AM
Super User
Posts: 7,771

Re: Executing .exe file thru SAS

Posted in reply to DanielSantos

To expand on @DanielSantos's example, I'd use this:

data _null_;
     infile '<myfile.exe> 2>&1' pipe;
     input; * read from output;
     putlog _infile_; * show it in the log;
run;

The 2>&1 reroutes stderr output to stdout, and so all messages are caught and written to the log.

 

Be aware that you may not be able to do this (or use any of the suggestions) if your SAS workspace server runs on a different machine or even on a different operating system.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Posts: 5,426

Re: Executing .exe file thru SAS

Call execute, call system or X statement.

For Enterprise Guide (or any other workspace server enabled SAS session), you need ALLOWXCMD option to be set.

Data never sleeps
Super Contributor
Posts: 474

Re: Executing .exe file thru SAS

Hi.

 

In addition and if you want to retrieve the output of that command you could use the pipe feature.

 

 

data _null_;
     infile '<myfile.exe>' pipe;
     input; * read from output;
     putlog _infile_; * show it in the log;
run;

 

Daniel Santos @ www.cgd.pt

 

Solution
‎02-13-2017 08:07 AM
Super User
Posts: 7,771

Re: Executing .exe file thru SAS

Posted in reply to DanielSantos

To expand on @DanielSantos's example, I'd use this:

data _null_;
     infile '<myfile.exe> 2>&1' pipe;
     input; * read from output;
     putlog _infile_; * show it in the log;
run;

The 2>&1 reroutes stderr output to stdout, and so all messages are caught and written to the log.

 

Be aware that you may not be able to do this (or use any of the suggestions) if your SAS workspace server runs on a different machine or even on a different operating system.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 33

Re: Executing .exe file thru SAS

Posted in reply to DanielSantos
Thank U
Contributor
Posts: 33

Re: Executing .exe file thru SAS

Thank U

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 336 views
  • 2 likes
  • 4 in conversation