Allan Bowe
Allan Bowe

Reputation: 12701

Determining Server Context (Workspace Server vs Stored Process Server)

I'd like to conditionally execute code depending on whether I'm in a Workspace or Stored Process server context.

I could do this by testing the existence of an automatic STP variable, eg _metaperson, but this wouldn't be very robust.

Assuming I already have a metadata connection, how best to check my server type?

Upvotes: 2

Views: 547

Answers (3)

Allan Bowe
Allan Bowe

Reputation: 12701

Hurrah - there is, in fact, an automatic variable that does just this - sysprocessmode (available since 9.4)

Extract from documentation:

SYSPROCESSMODE is a read-only automatic macro variable, which contains the name of the current SAS session run mode or server type, such as the following:

  • SAS DMS Session
  • SAS Batch Mode
  • SAS Line Mode
  • SAS/CONNECT Session
  • SAS Share Server
  • SAS IntrNet Server
  • SAS Workspace Server
  • SAS Pooled Workspace Server
  • SAS Stored Process Server
  • SAS OLAP Server
  • SAS Table Server
  • SAS Metadata Server

Being an automatic variable, it is of course read only: enter image description here

Upvotes: 2

Vasilij Nevlev
Vasilij Nevlev

Reputation: 1449

Bulletproof way would be to create a macro variable that is initialised by the autoexec or config in the required server context.

Of course this would only work if you have access and permission to modify files stored in sas configuration folder.

Upvotes: 2

Richard
Richard

Reputation: 27516

The stored process server will preset the _PROGRAM macro variable with the program that is running. I do not know if this macro variable is read-only in the STP execution context.

But as you say, a program in the workspace context could set a _PROGRAM macro variable.

For workspace sessions look for _CLIENTAPP macro variable.

I am unaware of a function to call or immutable system option that can be examined. Try PROC OPTIONS in both contexts and see what pops out. An OBJECTSERVERPARMS value, if reported, is a list of name=value pairs. One of them would be server= and may differentiate.

Upvotes: 1

Related Questions