2

I wish to execute a PC SAS program (myProgram.sas) using PowerShell.

I have tried

Start-Process -FilePath "C:\DatabaseManager\MGORD\Daily_SAS_LoadingFiles\myProgram.sas"

PC SAS opens the file but the code does not execute. How can I make the SAS program execute?

2
  • 2
    Pass the path to the PC SAS executable as the -FilePath argument, then pass the path to the myprogram.sas file as the -ArgumentList argument, perhaps? Commented Aug 30, 2019 at 15:17
  • Looks like you are trying to run the program file as if it was an executable file instead of running SAS and telling it what program to run. That is like trying to run a DOC file instead of running WORD and telling it what DOC file to open. Commented Aug 30, 2019 at 17:19

1 Answer 1

1

Start-Process with a file name will open the file with it's default open operation according to what is installed and configured. For instance, on my system the program opens into SAS Enterprise Guide.

Consider starting SAS itself and using command line arguments to set system options to do what you want. The are over 120 system options that can be set.

SYSIN

Submit program in batch mode. Creates log file in current folder.

Start-Process SAS -ArgumentList "-sysin ""C:\Temp\myProgram.sas"""

INITSTMT

Submit source code file in interactive mode.

Start-Process SAS -ArgumentList "-initstmt '%include ""C:\Temp\myProgram.sas"";'"

INITSTMT and DM

InitStmt can submit a DM string to execute any of the almost 80 SAS window commands. Careful attention to ridiculous quoting needed to perform this from command line.

FILEOPEN and SUBMIT will open source code file into enhanced editor and submit it.

Start-Process SAS -ArgumentList "-initstmt 'dm editor ""fileopen """"C:\Temp\myProgram.sas"""""";dm ""SUBMIT;"";'"

SASOACT

SASOACT.exe is a helper executable used by SAS context menu items in Windows Explorer. You can submit source code file from the legacy programmer editor window using SASOACT.

Start-Process sasoact.exe -ArgumentList "action=Submit datatype=SASFile filename=""C:\Temp\myProgram.sas"" progid=SAS.Application.940"

The commands can be found in the actions installation script, or in the registry. Submit is located at

HKEY_CLASSES_ROOT\SAS.Program.701\shell\Submit940\command
Sign up to request clarification or add additional context in comments.

2 Comments

How could I create the log file in a particular folder?
Do a CD to the folder prior to start, or use option -SASINITIALFOLDER <particular folder>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.