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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2930 views
  • 0 likes
  • 3 in conversation