DATA Step, Macro, Functions and more

Using PowerShell as wrapper to launch SAS

Reply
New Contributor
Posts: 4

Using PowerShell as wrapper to launch SAS

I have a number of data loads, reports etc that I process on a SAS windows server. I currently use .bat files to launch sas.exe and run the SAS program. I'd like to switch to Powershell scripts.

Has anyone had any experience using PowerShell to launch SAS. I'm particularly interested in passing condition codes from the SAS program back thru PowerShell to my scheduler (autosys) - want to only run job 2 if job 1 completed successfully.

Thanks in Advance
Super Contributor
Super Contributor
Posts: 3,174

Re: Using PowerShell as wrapper to launch SAS

Posted in reply to artmorlock
After searching these forums and the SAS support website, I found limited information on this topic/post. You may want to consider contacting SAS tech support directly for their input/guidance, as well as reviewing the available tech/conference references using an Internet search (and searching the forums).

Scott Barry
SBBWorks, Inc.
New Contributor
Posts: 4

Re: Using PowerShell as wrapper to launch SAS

Posted in reply to artmorlock
Thanks Scott,
I had opened a support ticket with SAS and they suggested I post the question in the forum. I'll experiment some and post my findings.
N/A
Posts: 1

Re: Using PowerShell as wrapper to launch SAS

Posted in reply to artmorlock
We are wondering if we can launch and run program in Enterprise Guide 4.2 with powershell? I can launch the program with powershell but can not "run" the programs within it.

As far as running SAS I found the following at

http://www.eggheadcafe.com/software/aspnet/32285102/questions-on-powershell.aspx

It works with SAS files, but I can not get it to work with Enterprise Guide

Start-Transcript -path 'C:\sas_works\joblog.txt'
$ErrorActionPreference="Continue"
Set-Location 'C:\program files\SAS\SAS 9.1'
.\sas.exe 'C:\sas_works\PGM1.sas'|Out-Null
$error=@($LastExitCode)
$error
if($error -ne 0)
{ "ERROR! Please recheck the SAS code.Thank You."
Stop-Transcript
Exit
}
else
{
Cat "C:\sas_works\location.txt" > "D:\location.txt"
Set-Location 'C:\sas_works'
Stop-Transcript
Exit
}
Exit
Ask a Question
Discussion stats
  • 3 replies
  • 344 views
  • 0 likes
  • 3 in conversation