Is there code that SAS can use to identify whether it's being run on SAS EG or Base SAS.
Basically, I want to create an condition that says if the user is using Base SAS then run "Code A'. If the user is running SAS EG then run "Code B"
Thanks in advance.
When you run SAS EG the code runs on a server.
You can check &SYSHOSTNAME macro variable for the host name.
And when I check the value of the &syshostname value on my SAS Display Manager (Base) the result looks like:
205 %put &syshostname;
DESKTOP-C36D7SF
I suspect the C36D7SF might change from install to install but the DESKTOP is likely to be sufficient.
I've always wanted a shortcut for this. I've never found one.
CAVEAT: this is too much art than science, it's not fool proof, I admit.
Run the command
%put _all_;
in both environments and check what macro variables exist.
For SAS/Studio you will see macro variables like these that you can check.
GLOBAL _CLIENTAPP 'SAS Studio' GLOBAL _CLIENTAPPABREV Studio GLOBAL _EXECENV SASStudio
I have used _CLIENTAPP in the past with EG.
So something like this:
%global _clientapp ;
%if %length(&_clientapp) %then %do;
* Running under EG or STUDIO ;
%end;
%else %do;
* NOT running under EG or STUDIO ;
%end;
What's the reason for running different code for EG users versus Base SAS users? There are other ways to set up different SAS environments for groups of users.
share it with us if you can. code and error log. the problem sounds interesting.
The variable _MetaUser could be used, too. It only exists if a connection to a metadata server is active, but i am not sure whether that variable exists when using a local sas installation with Enterprise Guide.
@SASKiwi One reason to run different code depending on the executing environment is calling proc printto only if a program runs as stored process and not while it is executed in Enterprise Guide.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.