We are still helping our customers get more out of the data they have and make data driven decisions. Our new site is packed with information and insights of how data can be the catalyst to your business growth.
Most SAS programmers are familiar with the use of an AUTOEXEC file which allows us to AUTOmatically EXECute a program on SAS invocation. What perhaps isn’t clear is how we go about doing the same thing using Enterprise Guide.
Enterprise Guide allows us to submit code on a SAS server. That server could be a SAS Application Server running on a different physical machine to Enterprise Guide or it could be a ‘Local’ SAS server, located on the same physical machine. In either case, the SAS ‘server’ in question is simply an individual SAS session which is still capable of running code at initialisation.
The conventional way of submitting code from a SAS Application Server is through one of the many autoexec files which are invoked on server initialisation. The ‘appserver_autoexec_usermods.sas’ file stored under the application server context can, for example, be used to supply initialisation instructions to any SAS client connecting to the server. The only problem with this approach is that not every user will have access to edit this file.
From a ‘Local’ SAS servers perspective, it is possible to submit code at initialisation by creating a file called ‘autoexec.sas’ within the SAS install location, and specifically within the sub-folder containing the SAS configuration file. The default location for this in SAS 9.3 is typically ‘C:Program FilesSASHomeSASFoundation9.3’.
There is however a simpler way to define initialisation code using Enterprise Guide.
Selecting, the ‘Tools’ menu followed by ‘Options’ displays a dialog containing a series of option categories in the left hand panel. Selecting the ‘SAS Programs’ category reveals a check box labelled ‘Submit SAS Code when server is connected’. When this is selected, Enterprise Guide executes all programming statements defined in the editor window displayed on selecting the ‘Edit…’ button. Code can either be entered directly within here, or if a generic autoexec file is to be used, a %INCLUDE statement could be used to reference a separate program.
The advantage of this approach is that the code specified will run on connecting to any SAS server. This can be verified by viewing the ‘Properties’ of the connected server in the ‘Server List’ window and selecting the ‘View Initialization Log…’ button on the ‘Software’ tab. This displays all of the code which Enterprise Guide has run during server start-up, including the custom initialisation code added.
Other viable alternatives for defining autoexec processing would be to define an ‘autoexec’ process flow which runs as the first set of tasks within a project. This would need to be recreated from project to project.
As an extension to this topic, programmers may wish to investigate some of the global macro variables which Enterprise Guide automatically assigns during start-up (_SASSERVERNAME for example) which could be used to conditionally run different statements based on the active server. It is also possible to export and share the initialisation code defined through the options dialog to ensure every users Enterprise Guide session runs the same code.