You asked for it: the Autoexec process flow

20

AUTOEXEC.SAS wasn't enough for you. Yes, it's a sure-fire way to run SAS statements (such as LIBNAME assignments or macro definitions) whenever you start your SAS session, but you found it has limitations when used in configurations with lots of users who connect with SAS Enterprise Guide. Limitations such as:

  • The statements in the Autoexec file will be run for everyone who connects to the server, whether they need them or not. It doesn't allow for very fine control.
  • Only an administrator can change the content of the Autoexec file. If a mere-mortal end user wants to inject his own autoexec processing, he has to petition the administrator to add it on his behalf. The admin then needs to consider the impact on the other users of the system.

You were clever though: you discovered an undocumented hook in SAS Enterprise Guide 3.0 and 4.1, where you could inject your own statements and have them submitted when you connected to a SAS session. By adding content to a not-so-secret file named EGAuto.sas, you could "fool" the system into doing your bidding.

Impressed with your ingenuity, the product team removed EGAuto.sas in SAS Enterprise Guide 4.2. In its place they established a formal option that does the same thing, complete with support and documentation. Within Tools -> Options -> SAS Programs you can select Submit SAS code when server is connected, then click Edit, then enter the SAS code you want to execute on the SAS server when you connect. It's all described for you in this sasCommunity.org tip about "user-specific autoexecs", and it's all you would ever need. Right?

Wrong! It wasn't enough to provide user-specific autoexec processing. You then asked for project-specific autoexecs, so that you could specify different actions that would happen automatically when you open different SAS Enterprise Guide projects.

SAS Enterprise Guide 4.3 adds this support, and it's easy to use. Simply add a new process flow to your project (File->New->Process Flow) and name it "Autoexec". You can put anything that you want in this process flow: a program with library assignments or macro definitions, one or more "Assign Library" tasks, Upload or Download data set tasks, even custom tasks. The Autoexec process flow helps you to get everything ready for you to work with your project.

an example project with autoexec stuff

When you open a project that contains an Autoexec process flow, SAS Enterprise Guide can run that flow automatically. By default, you'll see a prompt asking if that's what you want to do.

an example project with autoexec stuff

If you don't want to see the prompt, but just want that autoexec to run, well, automatically, you can change that behavior in Tools->Options.

There. That should keep you happy for a while. Right?

Share

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

20 Comments

  1. Most excellent. I have been using this feature in batch SAS for many, many years and found it a pain to manually re-run my project-specific libnames every time I opened an EGuide project.

  2. Pingback: 10 tips for organizing your SAS Enterprise Guide projects - The SAS Dummy

  3. Chris Hemedinger

    Great post Chris! The Autoexec process flow was just presented last month at out SUG meeting in Toronto and your post further clarifies what it does and how it developed over past releases.

  4. Thanks Chris for the rich and enjoyable read but i want more...

    Under the Submit SAS code when server is connected option, can i add a prompt to allow me to specify (as an example) a date that the program string will run with?

    • Chris Hemedinger
      Chris Hemedinger on

      Jong, you can't add a prompt to the "Submit SAS code when server is connected" option, but you could add a prompt to a program node in the Autoexec flow, and thus get a prompt right away in your project. But if the goal is to do some sort of "prompted" setup for all users, all projects -- there isn't a hook for that at the moment.

    • yes...I would like a prompt that let's me select the table that I want to use. I don't want to create a library each time I start work. I would like to just be able to select a table...

  5. Tried to use this tip but it doesn't work. Is there an option being set by the installer that is negating/disabling this feature? .

    • Chris Hemedinger
      Chris Hemedinger on

      No, it should work. It requires SAS Enterprise Guide 4.3, and the process flow name must be named "Autoexec" (case doesn't matter, but no additional characters allowed).

      If you continue to run into problems, contact SAS Technical Support with a sample project file. They'll be happy to look into it and see what the cause might be.

  6. Pingback: Demystifying SAS autoexec files - SAS Users Groups

  7. Pingback: Seeing SAS data through metadata - SAS Users Groups

  8. Pingback: Using Autoexecs with SAS Enterprise Guide

  9. I'm a bit behind on sas so my apologies. I like this feature and with task scheduler it works perfectly. Is there also a way to close the SAS project and app once the process flow has finished?

    • Chris Hemedinger
      Chris Hemedinger on

      There isn't a way to automate closing the project and app as part of running the flow. This is done automatically when you schedule/run a project in automation, of course (in script), but there isn't a "close project/app" function when running interactively in SAS Enterprise Guide.

  10. Is there an equivalent to the autoexec file that instead runs at the end of a session? I know through Tools >> Options >> SAS Programs, you can also specify code that runs when the server is connected... any way to get custom code to run on close of a session?

  11. Autoexec flow runs only when opening the project, isnt it?
    What about reconecting to a server?

    Thanks

    • Chris Hemedinger
      Chris Hemedinger on

      No, it applies only on project open. You can add SAS code (not EG task items) that runs when EG connects to the server: Tools->Options->SAS Programs.

  12. But Autoexec flow is project specific, and this option is for all user pojects.
    Hope this execution mode(Autoexec execution when reconnecting to server) will be added to E.Guide in future releases

  13. Pingback: Using Autoexecs with SAS Enterprise Guide

Back to Top