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
You should run your SAS programs in batch mode from a Powershell script. See this link for how to do it.
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.
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?
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.