BookmarkSubscribeRSS Feed
lbogar
Calcite | Level 5

Is it possible to pass parameters to another software program I want to call from SAS?  I'm trying to call a tool called LEGS which when you click on it it will open a terminal and ask you to input R or F and then your instructions file. Using this I get as far as the terminal asking R or F but I have no idea how to go about inputting the required prompts from SAS-

 

x start "" "P:\SAS PD\LEGS\G3\LEGS Release.exe";

 

Any insight is greatly appreciated!

3 REPLIES 3
Kurt_Bremser
Super User

You can't feed data into a prompt directly from SAS.

 

On UNIX, I would create a shell script which accepts commandline parameters and then uses expect to feed them to the target process.

Unless, of course, the target software accepts commandline parameters on its own (something which separates software from crapware IMO).

Peter_L
Quartz | Level 8

Your EXE file is running under Windows command CMD shell. You can redirect to the input of terminal-style programs like this:

echo R|"P:\SAS PD\LEGS\G3\LEGS Release.exe"

Echo sends R followed by end-of-line. It is more challenging to provide two lines. It might work to write your two lines to an external file and then have this CMD line:

<"myinput.txt" "P:\SAS PD\LEGS\G3\LEGS Release.exe"

It depends very much on how the EXE reads its input. In the worst case you might need something like AutoIT. Get it working outside SAS first, then make SAS provide what works.

Ref: Command Redirection, Pipes - Windows CMD - SS64.com 

An alternative is to write a CMD wrapper for your EXE which takes two parameters and provides them as described above. Then call the wrapper from SAS.

Ref: Call - Windows CMD - SS64.com

ballardw
Super User

Can you show a command line that behaves as if the value R or F are accepted?

Maybe something like this entered in a command prompt:

P:\SAS PD\LEGS\G3\LEGS Release.exe <R 

The redirect can be used to send a parameter to standard input depending on the program. If that works then you could create a SAS call that creates the appropriate call but that depends on Where is the R or F that you want set or stored? SAS cannot pass something it has not processed?

 

Which environment are you running SAS in? EG has a Prompt to submit such stuff, SAS Display manager can use the WINDOW data step functionality or the macro facility %WINDOW to request user input.

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 3 replies
  • 946 views
  • 0 likes
  • 4 in conversation