I am trying to executing SAS code in batch mode using Powershell to kick it off. Within the powershell code we assign the code to a variable call $SAS_APPLICATION_LOCATION and the code we are trying to assign to it as shown which the version that is use in a batch file:
"C:\Program Files\SAS\SAS 9.1\sas.exe" -sysin "E:\Propagator Import\Export PACS test data.sas" -fullstimer -ALTLOG "E:\codeshare\"
We are using the following to run the execute this job:
$ApplicationOutput = cmd /c $SAS_APPLICATION_LOCATION
We could not get it to work but we did get it work using Ping with one of our server.
Do anybody have any experience running SAS code in batch mode using PowerShell?
Thanks for your help in this matter.
Hi,
I'm only just starting to investigate this same thing, so my answer is not only belated (I only just saw your post) but half-baked as well.
Having said that, this works for me:
pushd "$env:userprofile\My Documents\My SAS Programs" $cmd="C:\Program Files\SAS\SASFoundation\9.2\sas.exe" $cfg="C:\Program Files\SAS\SASFoundation\9.2\nls\en\SASV9.CFG" $pgm="test1.sas" cmd /c " ""$cmd"" -config ""$cfg"" -sysin ""$pgm"" " # I also tried all of these, since I do not want to use cmd /c if at all possible # But, they do not properly set the $LastExitCode from SAS # Start-Process "$cmd" "-config ""$cfg"" -sysin ""$pgm"" " -Wait # Start-Process "$cmd" "-config ""$cfg"" -sysin ""$pgm"" " -Wait -PassThru # Start-Process "$cmd" "-config ""$cfg"" -sysin ""$pgm"" " -Wait -NoNewWindow "LastExitCode=$LastExitCode" popd
I've also posted here to try and get further help: http://www.powershellcommunity.org/Forums/tabid/54/aft/7999/Default.aspx.
But like I said, the above works for me.
Regards,
Scott
Thanks a lot.
It is good to know we have to add Start-Process before call sas.exe
Did anyone try call SAS EG Project from PowerShell?
I tried, but it only pops up EG window, not execute the Project Flow,
wondering what is the trick(or option) I have to give here?
Lynn
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.