This article contains supporting information for a SAS Global Forum 2012 paper: Not Just for Scheduling: Doing More with SAS Enterprise Guide Automation. While the paper is several years old, the techniques it describes remain the same and relevant for current versions of SAS Enterprise Guide. I've updated the code for many of the examples so you can try them with modern versions.
SAS Enterprise Guide supports a rich automation model that allows you to "script" almost every aspect of opening and running SAS Enterprise Guide projects. While this is most often used with the built-in "scheduler" function to simply run a project or process flow unattended, you can also write your own scripts that automate much more. You can create new projects on the fly, supply values for project prompts, run individual tasks, export results, and more. You're not limited to the traditional VBScript method of automation; you can also use more sophisticated frameworks such as Windows PowerShell or Microsoft .NET.
This paper describes the concepts behind automation for SAS Enterprise Guide, and provides examples to accomplish a variety of tasks using the different scripting technologies.
To watch me explain these concepts and to see a demo of building and running these scripts, watch this portion of my SAS Enterprise Guide "advanced techniques" tutorial.
To use each VBScript example, save the linked file to your local PC with a ".vbs" file extension. These are hosted on GitHub so you can click through and see a preview of the code.
You can then run the examples on your local PC with CSCRIPT.EXE, which is part of the Windows operating system. See this blog post for special considerations regarding the 64-bit versus 32-bit versions of CSCRIPT.EXE.
Here's an example of the first script, inline:
' force declaration of variables in VB Script
Option Explicit
Dim Application
' Create a new SAS Enterprise Guide automation session
' Change if running a different version of EG
Dim egVersion
egVersion = "SASEGObjectModel.Application.7.1"
Set Application = WScript.CreateObject(egVersion)
WScript.Echo Application.Name & ", Version: " & Application.Version
Application.Quit
And its output:
C:\automation>%windir%\syswow64\cscript.exe NewApp.vbs
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
Enterprise Guide, Version: 7.100.5.0
All VBScript examples have been updated and tested to work with SAS Enterprise Guide v7.1. If using SAS Enterprise Guide 8.1 or later (such as 8.3), change the object model version like this:
Dim egVersion
egVersion = "SASEGObjectModel.Application.8.1"
How to run Windows PowerShell scripts - post on The SAS Dummy blog
Using Windows PowerShell to report on SAS Enterprise Guide projects
"PowerShell"-tagged posts from The SAS Dummy blog
To use these PowerShell examples, save the files as PS1 files on your local machine, and then run them within a PowerShell console window or by using the powershell -command option.
All PowerShell examples have been updated and tested to work with SAS Enterprise Guide v7.1.
Getting Started with Microsoft .NET - Microsoft MSDN site, includes link to download the free "Express"/Community editions of Visual C# and Visual Basic.NET
SAS Enterprise Guide project file "searcher": EGPSearch (GitHub site file with EXE and source code)
Note: this example was built based on SAS Enterprise Guide 4.3 -- it won't run with later versions without modifications and rebuilding it.
This is a sophisticated example that shows how you can use automation and Microsoft .NET to create a tremendous productivity tool for managing your SAS Enterprise Guide projects. This tool allows you to search within a collection of EGP files to find any text within SAS programs, logs, notes, and generated code from tasks and queries.
A non-automation version of the EGP Searcher application is available here.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.