BookmarkSubscribeRSS Feed
JoshuaHarris
Obsidian | Level 7
Can we run SAS in cmd prompt by passing a .sas file without opening the SAS tool? Similar to how python code runs in the background if we pass python tst.py in cmd prompt
11 REPLIES 11
SASKiwi
PROC Star

It's called running SAS in batch mode. This link describes the details for SAS running on Windows.

JoshuaHarris
Obsidian | Level 7
Thank you for your quick reply. Can you please let me know if we can do the same for .egp files
JoshuaHarris
Obsidian | Level 7
I checked the below page created by Chris and couldn't find any ways that we could execute SAS egp files using cmd prompt. Also tried the powershell one, but couldn't change the execution policies as we using office system and it cannot be modified.
https://communities.sas.com/t5/SAS-Communities-Library/Doing-More-with-SAS-Enterprise-Guide-Automati...
Will wait for Chris to respond with some solution or workaround
SASKiwi
PROC Star

Correct, you can't run EG projects from a command line. You can run them from VBScripts though and you can export the SAS code from your project if you must use a command line.

Kurt_Bremser
Super User

SAS in batch mode is only possible when you have a local SAS installation, or have access to the commandline on the SAS server.

To run an Enterprise Guide project in batch, you need to run software that mimics EG (or uses EG in "background" mode), and this is described by @ChrisHemedinger 's articles.

EG provides the option of exporting the whole project code to a single .sas file, but this is only helpful if you do not use task nodes that use EG's special capabilities (importing/exporting, Copy Files, ..).

 

EG itself should provide an OOTB option to do this from the commandline, like

saseguide -project "path-to-project.egp" -run

IMHO

Nigel_Pain
Lapis Lazuli | Level 10

That's a nice idea. I think the difficulty (not insurmountable, of course!) would be that an EG project isn't necessarily one straight flow of code. There can be multiple process flows, so you'd need to have some way of specifying the one you want to run.

Kurt_Bremser
Super User

Of course, the commandline needs to reflect the capabilities of the software itself, so one would also need a -flow option (or the -run could optionally accept a flow name). And probably a -autoexec option which forces EG to execute the Autoexec flow even when it is not configured to do this per the settings.

Kurt_Bremser
Super User

But mind that in all my work I have never run a project in batch mode (even though EG was my main interface to SAS, and my main development tool). All automation was always done by running .sas files in SAS batch mode from a scheduler, on the SAS server.

ChrisHemedinger
Community Manager

The automation / scripting APIs allow for "batch" and scheduled running of projects, but as others have pointed out it's not a native command-line interface for SAS Enterprise Guide. Instead you build a simple script (could be VB Script or PowerShell) and run the script from the command line.

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
AllanBowe
Barite | Level 11

For info - we have built an open source server that provides a full REST API onto Base SAS.  Just point it at your SAS executable, add your SAS programs, and you can execute them easily from any language.

 

The benefit of this approach is that the projects you build can be very easily migrated to Viya in the future.

 

https://github.com/sasjs/server

 

/Allan
SAS Challenges - SASensei
MacroCore library for app developers
SAS networking events (BeLux, Germany, UK&I)

Data Workflows, Data Contracts, Data Lineage, Drag & drop excel EUCs to SAS 9 & Viya - Data Controller
DevOps and AppDev on SAS 9 / Viya / Base SAS - SASjs

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 11 replies
  • 10685 views
  • 3 likes
  • 7 in conversation