BookmarkSubscribeRSS Feed
thesasuser
Lapis Lazuli | Level 10

Hello
We are running SAS EG on the Desktop and SAS on a remote server running Windows OS.
The moment a user connect to the server it executes and Autoexec.sas  (and Autoexec_usermod.sas specified in it) in the [SASRoot]. The same Autoexec.sas (and the autoexec_usermod) executes for different teams with different teams.
Was thinking of a custom autoexec for each team.
Using the "Automatically run the Autoexec process flow" is not a feasible option. 
Similarly "insert custom code before" is also not a feasible option.
Wondering if there is some way to use a custom autoexec instead of the Autoexec in SAS Root.
I have already looked at the following and could not find something relevant for my case (or have I missed it?)

https://communities.sas.com/t5/SAS-Enterprise-Guide/Enterprise-Guide-how-to-run-program-at-startup/t...  

https://blogs.sas.com/content/sgf/2014/05/01/autoexecs-the-sas-enterprise-guide-advantage/  

Any help is highly appreciated.


3 REPLIES 3
LinusH
Tourmaline | Level 20

There are probably many ways of doing this, so it may come down to your requirements.

How many teams are there that need separate autoexec?

First, I don't think you should bypass the existing set up with the central ones.

The different option within EG will distribute the logic from the server. This will be question of governance.

On the server you could create separate compute contexts (e.g. other SASApp's). This a quite a change and feasible if you don't too many groupings and want other separation between you user groups.

Maybe you could have a %include code in your central autoexec (with some kind of logic that pickup users group and select the appropriate .sas file), or %if %then %else sections in your autoexec code.

 

Data never sleeps
Quentin
Super User

I'm not an admin, but I think if you want a different autoexec for each team, you would need to set up a different (logical?) SAS server for each team.

 

Another way you can approach this is to create a utility macro %setup(teamname)  which each program would call at the beginning.  (Or could be called automatically when EG connects to the server).  I tend to use the %setup() approach as I like to see my code in the program and log, rather than depend on an autoexec.  Also as a user, I can maintain the definition of %setup() but typically can't muck with autoexecs.  This also tends to make code more portable when it is run on different servers (as DI job, stored process, or whatever).

The Boston Area SAS Users Group is hosting free webinars!

Register now at https://www.basug.org/events.
sbxkoenk
SAS Super FREQ

@thesasuser wrote:

Was thinking of a custom autoexec for each team.
Using the "Automatically run the Autoexec process flow" is not a feasible option. 
Similarly "insert custom code before" is also not a feasible option.
Wondering if there is some way to use a custom autoexec instead of the Autoexec in SAS Root.


The two options you label as "not a feasible option" are described in this video:
SAS Tip: Automatic Code Execution with SAS Enterprise Guide
https://www.youtube.com/watch?v=OzFYNw7Bntg

 

I would still select the “Submit SAS code when server is connected” - option (for Initialization Code).
But in the pop-up window ... you put code that executes conditionally (by means of a macro that you define and call).
Based on the user ID (automatic macro variable "sysuserid"), you determine which team a user belongs to. Then you use a %INCLUDE to load the autoexec file for that team.

 

  • %INCLUDE "\\fileserver\teams\teamA_autoexec.sas" / source2 ;
  • %INCLUDE "\\fileserver\teams\teamB_autoexec.sas" / source2 ;
  • %INCLUDE "\\fileserver\teams\teamC_autoexec.sas" / source2 ;
  • ...

BR, Koen

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch Now →
Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 86 views
  • 0 likes
  • 4 in conversation