Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAS program that detects if it runs in SAS base or SAS EG

Tags:

sas

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?

like image 291
Rud Faden Avatar asked Sep 03 '15 06:09

Rud Faden


2 Answers

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
like image 89
kl78 Avatar answered Oct 19 '22 15:10

kl78


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();
like image 3
Dmitry.Kolosov Avatar answered Oct 19 '22 16:10

Dmitry.Kolosov