Doing more with SAS Enterprise Guide automation


Have you ever selected File->Schedule Project or Schedule->Process Flow in SAS Enterprise Guide? Are you curious about what magic these actions will trigger?

Here's what happens:

  • SAS Enterprise Guide creates a VBScript program that contains the instructions to start SAS Enterprise Guide, load your project, run your project or flow, and save the results.
  • SAS Enterprise Guide launches the Windows Task Scheduler interface, so that you can specify when and how often to run your project/flow unattended.
  • The scheduled task contains the command (CSCRIPT.EXE) and a reference to the VBScript (VBS file), which Windows will run at the appointed time. (Learn more about this mechanism at "Using SAS Enterprise Guide to run programs in batch".)

The VBScript instructions drive the SAS Enterprise Guide automation API, and that API is capable of much more than simply loading and running your project. And you aren't stuck with VBScript -- you can access the automation API using Windows PowerShell and Microsoft .NET.

As the following diagram shows, the automation interface is a peer to the main user interface for SAS Enterprise Guide. Like the happy gentleman pictured at the top of the diagram, most users will interact with the main windows of SAS Enterprise Guide. Users gain access to this user interface by using the primary executable (SEGuide.exe), often by way of a desktop shortcut icon. With automation,you forgo the SAS Enterprise Guide user interface entirely, and you instead script every action using the automation API.

These are the concepts and examples that are the subject of my SAS Global Forum 2012 paper, Not Just for Scheduling: Doing More with SAS Enterprise Guide Automation. I will present this topic at the conference on Wednesday morning at 8am (with coffee in hand, most likely).

Check out my summary page on SAS Support Communities for links to the paper, blog posts, and several examples. The examples include:

  • A VBScript example that can extract all of the SAS programs and SAS logs from your project file.
  • A PowerShell example to create a simple listing of all of the tasks and input data within your project file.
  • A Microsoft .NET example (implemented with C#) that allows you to search for any text within your project file.

That last one is of special interest (and worthy of a separate blog post later). Even if the automation API isn't your thing, you might enjoy the EGPSearch example, which allows you to search a collection of SAS Enterprise Guide project files for any text within your SAS programs, logs, notes and more.


About Author

Chris Hemedinger

Director, SAS User Engagement

+Chris Hemedinger is the Director of SAS User Engagement, which includes our SAS Communities and SAS User Groups. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies


  1. My employer (a large European bank) has, in their infinite wisdom, seen fit to disable Windows Scheduling functionality on my PC - that being said, the VB scripts are still great for running a project from Windows Explorer with just a double-click of the mouse

    • Chris Hemedinger
      Chris Hemedinger on

      Bob, your situation is not uncommon.

      The Windows Scheduling privilege is tied up with other admin capabilities on the PC, and so while IT policies (justifiably) restrict these admin privileges, the ability to use local, personal scheduling is also disabled.

      Fortunately, there are 3rd party scheduling apps (some free, some paid) that can help. Combined with a bit of scripting knowledge, you can easily create your own scripts/batch/command files that would run at an appointed time.

      • Hi Chris,

        One of my user tried to schedule the EG Process flow and set up auto execution with trigger time and date. but the EG Flow not getting executing as accepted.
        can you please guide me what is stopping here and would i be able to see any logs on this?


        • Chris Hemedinger
          Chris Hemedinger on

          CG, are you scheduling with Windows Task Scheduler? Is it possible that the tasks aren't actually starting? Or maybe you need to supply credentials when the project runs unattended. There a few things that can go wrong when you schedule a job with Windows Task Scheduler. I recommend trying to use a simple script first, test running it from the command line with CSCRIPT.exe, and then schedule it to run while you're available to see the results. You can also turn on application logging (in Tools->Options), and you should see additional logs generated when EG runs automated (find these in %appdata%\SAS\EnterpriseGuide\7.1\Logs).

  2. Chris,
    Thank you for writing about this feature. Until I read your article, I did not know there was a way in EG to schedule projects. I am sure this will be very useful.

    Thank You

  3. Chris,
    thank you very much for posting this article. In my actual project we use Tosca, a testmanagement suite. Tosca offers several engines for DB-systems, UIs and program languages - but not for SAS. Our previous testactivities where affected by a lot of manual operations.
    Concerning to your post it is now possible to access the whole SAS I-platform from within TOSCA via the automation API. This is the first step to fully automate tests in TOSCA and will bring the whole testprocess in our project to a very higher level.
    Again - thank you very much

  4. Pingback: How much time will your process flow take to run? - The SAS Dummy

  5. Pingback: How to search your SAS Enterprise Guide project files - The SAS Dummy

  6. Pingback: I’m a WUSS and proud of it - The SAS Dummy

  7. Pingback: Using SAS Enterprise Guide to run programs in batch - The SAS Dummy

  8. Hello Chris,
    I am using your EGPSearch example as a starting point to make a generic C# program to kick off SAS tasks. I was wondering if you had any pointers on how to go about passing parameters to the SAS programs in the EG project... like a global variable. Any help appreciated!

    • Chris Hemedinger
      Chris Hemedinger on


      Check out the technique in this blog about running programs in batch via automation. You can use automation to open the EG project, then "add" a new program item to the CodeCollection. Set the text of the program to LET PARAM=VALUE; and then call the Run method. That essentially sets your "global" macro variable for your session, which you can reference through the remainder of the EG project.

  9. Pingback: Four ways to schedule SAS tasks - SAS Users Groups

  10. Pingback: Process Interruptus: a custom task to pause your process flow - The SAS Dummy

  11. Chris,

    Thanks for your Blog.It really helps in understanding the backend scenario.
    Could you Please help me with a document of steps by which we can schedule jobs in SAS EG , a pictorial representation is preferable.
    Thanks in Advance.


  12. Pingback: Testautomatisierung in TOSCA mit dem SAS Enterprise Guide (4.3) – ARS IN4MATICA

  13. Hi Chris,

    We are migrating from SAS EG to SAS Grid. And I am made aware (not sure yet) that only .sas file runs in SAS Grid scheduler and not the whole set of task icons present in SAS EG. For example, the 'Copy File To/From folder' may not be working in SAS Grid when scheduled. Is there a work around for this?


    • Chris Hemedinger
      Chris Hemedinger on


      Since the Copy Files task does its work outside of SAS code, there isn't a way to convert this task directly. However, there are some other methods for copying files around the network, including FILENAME FTP and some "copy file" macros that I've shared on the blog. Perhaps you can adapt your process to use something like that?

  14. Hi Chris, Thanks a ton for sharing your knowledge. I have task something like this User sends an email --> Automatically SAS code is run in background --> Automatically reply is sent to user with report.

    Now i have managed to create a vbs and part 1 and 2 of the code, somehow i am unable to get the third part i.e. once code is executed, how do i reply to the same person. I have working SAS EG 5.1 and Microsoft outlook. To be even more specific, i want to create a macro variable as soon as I get a mail from user and use that variable at the end of my code to send automatic reply.
    Any help / idea/code snippet would be really helpful.

    Thanks a lot in advance

  15. Yes Chris.. I am using exactly the same example as reference. However , I am unable to get thr macro variables inside and also unable to get the same users email address to reply to.. I guess there has to be some vbs specific code for that ..

    • Chris Hemedinger
      Chris Hemedinger on

      I think you would need to use the CodeCollection to add a new program that %put the macro variables you want, and then you would need to use the .Log property on the Code object to retrieve the log text and then parse it. It's a bit tedious, but I think it's possible.

  16. Apologies in advance for the dumb question (I'm new to SAS) but will scheduling the project in this way still work if the local machine is off? I.E. if I schedule it to run at midnight, I don't have to wake up and turn on my computer at midnight to make it run, do I?

    Thank you!

    • Chris Hemedinger
      Chris Hemedinger on

      Fraser, yes - you do need to have your PC turned on. This scheduling uses Windows Task Scheduler, which can be triggered only if the machine is powered on and connected to the network. If you need to schedule a job outside of this, you would have to export the SAS program code and schedule a batch SAS job, or centralize your SAS Enterprise Guide projects and schedule from an always-on machine.

  17. Hi Chris,
    I am currently trying to automate few SAS EG reports. I scheduled the SAS EG project from which a VBScript is generated. Then I wrote a batch file with cscript.exe path(from local system) and the Vb script path which generated from SAS EG project.
    Till now I have tested and everything is good, reports are getting generated in my designated folder automatically. Till now I tested them on my local system, Windows task scheduler and it worked fine.
    And now my question to you is..., I will be using the batch file and integrate it with Tidal scheduler in the server.
    What are the things which needs a change for running the reports on a server automatically. Please need your help on this.
    Thanks a lot in advance...

    • Chris Hemedinger
      Chris Hemedinger on

      This method of automation is actually driving SAS Enterprise Guide to perform work for you, unattended. If you move the scheduled script off your current machine, then you won't have SAS Enterprise Guide to automate (unless you install it on the central server and make sure your project files are also available to it).

      What people typically do here is Export the contents of the SAS Enterprise Guide project as a SAS program. However, not all tasks and process flow logic translates into SAS code, so you would need to evaluate/test how this might work for you.

  18. We are about to implement a development and a production environment.
    Ie develop EG projects in DEV and when successful promote to Production.

    The projects can quickly be repointed between DEV and Prod environments.

    Our problem is in ensuring all datasets used in DEV are available in PROD
    To this end we need to know all of the data sets used by the Project in DEV and then ensure they are available in Prod. The tool in EG 4.3 "Project Maintenance " shows exactly what we need to know ie all of the datasets it uses or creates and whether they are an input or an output.

    Is there anyway to get all of this detail out of the EG project. in one pass.


  19. Hi,
    I am completely new to SAS platform, we have application with build on SAS platform with .Net technology.

    We are from testing team, trying to automate the application using UFT 12.02.

    But objects are getting identified as win-objects.

    I have selected .NET add-in. would require your guidance for automation the application.


  20. Hi Chris,

    I would like to know how to use the SAS Enterprise Guide scheduling tool in a Citrix environment.

  21. We are just moving from Desktop to SAS Office Analytics on a server. I have a VBS script which runs 3 EG projects sequentially each work day morning. But we have not installed EG on the server and would like the server to run the job before I arrive at work. What approach would you recommend?

    • Chris Hemedinger
      Chris Hemedinger on

      If you can install EG on a server, then you can schedule the projects centrally. If your desktop machine is always connected, then you should be able to schedule on your current desktop -- the Windows Task Scheduler will log in for you if you store your credentials with the job.

      But if none of that can work, you might need to export a SAS program version of the work that your project does, and schedule the .SAS job on your central SAS session using Windows Task Scheduler on the server (if Windows) or cron if using UNIX.

      • Thanks Chris
        We have installed EG on the server and created a sasbatch account to run the jobs. Now just need to get it working.

        • Hi Chris

          I am having trouble getting a scheduled task to run a EG process flow in a project. I have been able to get the windows scheduler to run an EG project which only had 1 simple program. But when I try to change the VB script to run the process flow it stops working. I have tried using the VB code that SAS EG generates to run the process flow but cannot get it working.

          The process flow works fine if manually running the branch from within EG. I used to have this process flow scheduled on a SAS desktop licence and it worked fine with an older version of EG.

          Any thoughts of what to try next?

  22. Hi Chris,

    It appears that my company has something set up on our SAS server that will not allow me to save my login credentials in an EG project. Because of this, when I schedule a project to run unattended, I get an error that the server is prompting for the login credentials and it won't run. I am trying to figure out a way to pass these credentials via the .vbs file or if there is another way to make this work? I hope you have some suggestions.


  23. Hi Chris,

    My users saved SAS EG projects and code SASApp server which creates sas datasets into SASApp server file system(read source data from local pc or SAS server file system location).
    Can I use File > Scheduel Project option for the eg projects which are in SAS server not in local system where EG got installed?

    For testing, i did save one of the project to local PC 'test' and ran successfully.

    I tried to open the 'test.egp' then File > schedule test > enter the schedule time, but not working.

    How to schedule the project called 'test'?


    • Hi Chris,

      Users read data from Unix file system and local PC(for some programes) and save the SAS EG projects and code in SASApp server(Unix) which creates sas datasets into Unix file system.
      Can I use File > Scheduel Project option for the eg projects which are in SAS server not in local system where EG got installed?
      For testing, i did save one of the project to local PC and named 'test' and ran successfully.
      I open the 'test.egp' then File > schedule test > enter the schedule time, but not working.
      How to schedule the above created project 'test'? if i schedule the test project does it created the final output table into SAS Server(Unix) file system as users expected?


    • Chris Hemedinger
      Chris Hemedinger on

      I do this all of the time. SAS Visual Analytics (whether using LASR with SAS 9 or CAS with SAS Viya) supports the concept of autoloading. Using this technique you would set your process to create output data sets and store them in a "drop zone". Then, use the admin tools in SAS VA (or SAS Viya) to automatically load those data sets on a regular schedule (daily or perhaps multiple times through the day if you need that).

      Resources: Autoload with SAS VA 7.5, SAS Viya Autoload (community article)

Back to Top