BookmarkSubscribeRSS Feed
Abhinav26
Obsidian | Level 7

Using the ways listed below to call the SAS code in powershell script:

 

#Step 2: Execute the SAS code
#Start-Process SAS -ArgumentList "-sysin ""C:\Users\apal1018\Desktop\Work\PHR automation\MY\Test.sas"""
#Start-Process SAS -ArgumentList "-initstmt '%include ""C:\Users\apal1018\Desktop\Work\PHR automation\MY\Test.sas"";'"
#Start-Process SAS -ArgumentList "-initstmt 'dm editor ""fileopen """"C:\Users\apal1018\Desktop\Work\PHR automation\MY\Test.sas"""""";dm ""SUBMIT;"";'"
Start-Process sasoact.exe -ArgumentList "action=Submit datatype=SASFile filename=""C:\Users\apal1018\Desktop\Work\PHR automation\MY\Test.sas"" progid=SAS.Application.940"

 

Getting same error everytime: 

PS C:\Users\apal1018> Start-Process sasoact.exe -ArgumentList "action=Submit datatype=SASFile filename=""C:\Users\apal1018\Desktop\Work\PHR automation\MY\Test.sas"" progid=SAS.Application.940"
Start-Process : This command cannot be run due to the error: The system cannot find the file specified.
At line:1 char:1

+ Start-Process sasoact.exe -ArgumentList "action=Submit datatype=SASFi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Start-Process], InvalidOperationException
+ FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

4 REPLIES 4
SASKiwi
PROC Star

You should run your SAS programs in batch mode from a Powershell script. See this link for how to do it.

Abhinav26
Obsidian | Level 7

This link has so many information.

Could you please help me in identifying which part we need to copy and create environment favorable for SAS codes execution in batch mode.  

DaanDNR
Obsidian | Level 7

is there any particular reason you use sasoact.exe instead of sas.exe? What happens if you execute the command in a cmd prompt? It seems that the system can't find the exe? Either specify the whole path or add the exe to the path?

SASKiwi
PROC Star

You run this command:

”c:\Program Files\SASHome\SASFoundation\9.4\Sas.exe” -sysin c:\SASPrograms\prog1.sas -config ”c:\Program Files\SASHome\SASFoundation\9.4\sasv9.cfg”.

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