BookmarkSubscribeRSS Feed
AllenJ
Fluorite | Level 6

Our company's engineering department developed a python script API to be used by clients.  Our department has be asked to verify the results.  There is a wide range of input possibilities so we would like to use SAS to create the formatted file of input and parse the output file for analyses.  We are running SAS 9.4.  I am trying the x command, and the python window flashes and an output file is created but is empty.  I am left with a Windows open box with c:\users\ajohnson open.  I have run the input file through a Windows bat command file and interactive python and the file is created and populated.  below are the x command and input py file.

 

x 'START /WAIT "C:\Python27\python.exe" "R:\API tests\temp_new.py" > "R:\API tests\temp_out_new2.txt" ';

 

Any suggestions of how to get the python script to show any error messages?  How do I get the output file with results?  Do I need to change "print results" to another python command?  How do I get the addditonal open box closed so I can run the SAS code in batch?

 

 

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

This discussion should interest you.

In particular, see what settings you have for options xwait and xsync, and try using a batch file.

 

Also, consider using

filename CMD pipe "OS command";

data _null_;

  infile CMD;

  input;

  put _infile_;

run;

 

instead of

x "OS command";

 

to capture the text returned by the OS.

 

 

enatx
Calcite | Level 5


Our company's engineering department developed a python script API to be used by clients.  Our department has be asked to verify the results.  There is a wide range of input possibilities so we would like to use SAS to create the formatted file of input and parse the output file for analyses.  We are running SAS 9.4.  I am trying the x command, and the python window flashes and an output file is created but is empty.  I am left with a Windows open box with c:\users\ajohnson open.  I have run the input file through a Windows bat command file and interactive python and the file is created and populated.  below are the x command and input py file.

 

x 'START /WAIT "C:\Python27\python.exe" "R:\API tests\temp_new.py" > "R:\API tests\temp_out_new2.txt" ';

 

Any suggestions of how to get the python script to show any error messages?  How do I get the output file with results?  Do I need to change "print results" to another python command?  How do I get the addditonal open box closed so I can run the SAS code in batch?

 

 


Check this - View solution in original post

Hope this will help you.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 7007 views
  • 1 like
  • 3 in conversation