BookmarkSubscribeRSS Feed
NickK
Fluorite | Level 6

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. 

8 REPLIES 8
Shmuel
Garnet | Level 18

When you run SAS EG the code runs on a server.

You can check &SYSHOSTNAME macro variable for the host name.

ballardw
Super User

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.

PhilC
Rhodochrosite | Level 12

I've always wanted a shortcut for this.  I've never found one.

  • Enterprise Guide will generate a series of "_CLIENT" macros variables.  You can test for their existence.  Base SAS will not create them automatically.
  • If Base SAS batch mode is running, and idealy, if one has not directed the log to another file, then there will be two file references in DICTIONARY.EXTFILES with the same path and filename, with one difference.  One will be the program with the extension ".sas" and the other, the log, with ".log".

CAVEAT: this is too much art than science, it's not fool proof, I admit.

Tom
Super User Tom
Super User

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;
SASKiwi
PROC Star

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. 

NickK
Fluorite | Level 6
Some users prefer to use EG, some base SAS. I have a script that send program info to an SQL database. The code works in EG but not in Base SAS
PhilC
Rhodochrosite | Level 12

share it with us if you can.  code and error log.  the problem sounds interesting.

andreas_lds
Jade | Level 19

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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 768 views
  • 3 likes
  • 7 in conversation