I'm writing a program that needs different information whether or not in runs in SAS base or SAS EG. Is it possible to write a SAS program that detects whether it is run in SAS EG or SAS base?
You can use the global macro-Variable _CLIENTAPP to test if you are in EG.
When you use for example:
data _null_;
%put &_CLIENTAPP;
run;
in EG 5.1 it returns 'SAS Enterprise Guide'.
_CLIENTVERSION returns the E.G. Version, e.G.:'5.100.0.15040' for my environment
Not sure if these globals exist in Base (can not test this at the moment), but if its not working, you could assume something like if variable not exists its base, e.G.:
if "&_CLIENTAPP" = 'SAS Enterprise Guide' then
*do eg stuff
else
*do base stuff
By SAS Base do you mean the batch mode? There is an automatic macro variable called SYSPROCESSNAME which can be used to distinguish batch and interactive modes.
In batch mode its value is the name of the program which you are executing. In EG and in SAS Studio its value is "Object Server" In DMS the value is "DMS Process" (or "DMS Process (2)" if you are running a second session).
If you need to distinguish between SAS EG and SAS Studio, you should use the solution with _CLIENTAPP written by kl78 in this topic.
Sample code which determines your current mode:
%macro whereDoesItRun();
%if (%superQ(sysProcessName) eq %quote(Object Server)) %then %do;
%if %symexist(_clientApp) %then %do;
%if (%quote(&_clientApp) eq 'SAS Studio' or %quote(&_clientApp) eq 'SAS Enterprise Guide') %then %do;
%put Running in &_clientApp;
%end;
%else %do;
%put Running unknown client &_clientApp;
%end;
%end;
%else %do;
%put Running unknown client;
%end;
%end;
%else %if %index(%superQ(sysProcessName), %quote(DMS Process)) %then %do;
%put Running as &sysProcessName;
%end;
%else %do;
%put Running %qScan(%superQ(sysProcessName), 2, %str( )) in batch mode;
%end;
%mend whereDoesItRun;
%whereDoesItRun();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With