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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 2 replies
  • 6939 views
  • 1 like
  • 3 in conversation