Home | Index | About | Contact
e-lections Know How motto Know Why motto Share motto Apply motto
Science funnel
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

SAS Programming Tips: Using Autoexec files with SAS Enterprise Guide

Leonid Batkhan | June 2013

http://www.e-lections.us/sas-tips-enterprise-guide-autoexec-usage.html


Introduction

Automatically executable files also known as autoexec files, proved to be very handy when using SAS either in an interactive mode or in a batch mode.

Autoexec files are routinely used to set up SAS data and format libraries, macro variables, SAS system options, etc. The Autoexec file gets automatically executed when the SAS System starts up.

Here is a typical SAS autoexec file:

	%let saspath = D:\SAS\Lev1\SASApp\SASEnvironment;
	%let projpath = D:\Projects\proj1;

	/* SAS format library */
	libname fmtlib "&saspath\SASFormats";

	option
   	   fmtsearch=(fmtlib)
   	   nodate
   	   mautosource sasautos=('!SASROOT\sasautos', "&saspath\SASMacro", "&projpath\code")
   	   ;

	/* Input data library */
	libname dwlib ODBC datasrc=PROD_DTA schema=DBO user=Sasread PASSWORD="{sas001}T8teQzIkMq==" access=readonly;

	/* Output data library */
	libname rptlib BASE "&projpath\outdata";

	/* Report folder */
	filename htmlout "&projpath\reports";

For autoexec usage with SAS System see SAS 9.3 Companion for Windows or SAS 9.3 Companion for UNIX Environments.

SAS Enterprise Guide

SAS Enterprise Guide provides an even better flexibility in SAS auto executable code usage. You can customize the autoexec start-up sequence in SAS EG by using either user-specific autoexec or project-specific autoexec, or both.

User-Specific Autoexec

In Enterprise Guide 4.3, autoexec code can be set up to execute every time a connection to a workspace server is made:

  • From the top Menu bar: Tools -> Options ->SAS Programs
  • In the Additional SAS code section, select the checkbox for Submit SAS code when server is connected
  • To the right of this checkbox, click the Edit button and enter the code to be run whenever you connect to a workspace server. You can also reference an external SAS autoexec file:
    	%include '/path/autoexec.sas';
  • Click the Save button to close the Edit window
  • Click the OK button to save and close the Options window

EG Options -> SAS Programs: Submit SAS code when server is connected

As you can see, there are two other options available to execute Additional SAS Code:

  1. Insert custom SAS code before submitted code
  2. Insert custom SAS code after submitted code

These auto executable Additional SAS Codes are stored as customization options in the user's instance of the SAS Enterprise Guide and therefore are user-specific.

Project-Specific Autoexec

However, you can also have an additional "layer" of customization pertinent to a specific SAS EG project.

Autoexec process flow

In an EG Project Tree, you can create a process flow named "Autoexec" that can be run automatically whenever you open your project. For example, you could use this process flow to define libraries or to assign macro variables for the project.

Add a new process flow to your project (File->New->Process Flow) and name it "Autoexec":

EG Autoexec project flow

You can put anything 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 get everything ready for working with your project.

A project can contain only one process flow named autoexec.

Running Autoexec with a prompt

By default, when you open a project that has an Autoexec flow you are prompted to run the Autoexec process flow. You will see the following prompt asking if that's what you want to do:

Popup: Run the Autoexec flow?

Running Autoexec automatically (without a prompt)

However, having this prompt pop up every time might be annoying, and you may want to disable it. You can specify an option to have the autoexec process flow run automatically without a prompt every time you open the project. In order to do this:

  • From the top Menu bar: Tools -> Options ->General
  • Select the checkbox for Automatically run "Autoexec" process flow when project opens
  • Click OK button to save and close the Options window.

EG Options -> General: Automatically run "Autoexec" process flow when project opens

Conclusion

Autoexec is a very convenient and powerful productivity feature of SAS Enterprise Guide. Use it to your advantage.

 
Terms of Use | Submit an Article | Contact