BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mathias
Quartz | Level 8

Hi,

I have code that is sometimes executed normally (windows sas 9.2, EG 4.3) and sometimes executed via a stored process

(the two are linked together in Eguide)

I would like to execute code only if It's running from a stored process.

%If (this is running in a stored process)

     %then %do;

     %stpbegin;

     %end;

I thought to do it with a system variable but I couldn't find any that gives such information.

thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

I do not have access to run stored process, but when I played with EG a few years ago I found that I could tell if I was running code from EG because it created macro variable _CLIENTAPP.  It also created macros (not variables) name ENTERPRISEGUIDE and _EG_CONDITIONAL_DROPDS.  I am not sure if that is still true or if it would distinguish between code submitted via EG vs stored process execution.

View solution in original post

5 REPLIES 5
Quentin
Super User

Hi,

I don't understand what you mean by executed normally vs executed via a stored process.  Can you explain a bit more?

Is the code executed by Enterprise Guide in each scenario?

Are you saying you have a stored procedure, and the source code of the stored procedure %includes some other code?  And you want to tell if that second bit of code has been %included by a stored process or not?

Thanks,

--Q.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
mathias
Quartz | Level 8

Hi,

A: Executed normally = a program executed by Eguide

B: executed as Stored Process = Stored Process executed by EGuide OR executed by web (Stored Process Web Application)

Lets say I have this little bit of code:

%If &MyCondition

     %then %do;

          %stpbegin;

     %end;


I need to find the right condition to make this code do nothing when A and do "%stpbegin" when B.

Let me know if I'm not yet clear enough,

Thanks,

Tom
Super User Tom
Super User

I do not have access to run stored process, but when I played with EG a few years ago I found that I could tell if I was running code from EG because it created macro variable _CLIENTAPP.  It also created macros (not variables) name ENTERPRISEGUIDE and _EG_CONDITIONAL_DROPDS.  I am not sure if that is still true or if it would distinguish between code submitted via EG vs stored process execution.

mathias
Quartz | Level 8

That's exactly what I was looking for Smiley Happy

%put &_CLIENTAPP;

A:

'SAS Enterprise Guide'

B:

SAS Enterprise Guide; CLR 2.0.50727.3620; Microsoft Windows NT 5.1.2600 Service Pack 3

OR

StoredProcessService 9.2; JVM 1.6.0_16; Windows Server 2008 (amd64) 6.1

Thanks !

mathias
Quartz | Level 8

Final thing :

%macro conditionalstpbegin() / store

DES='Conditionally executes %stpbegin';

  %put &_CLIENTAPP;

  %if &_CLIENTAPP = 'SAS Enterprise Guide' %then %do;

  %put Not Stored Process °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°;

  %end;

  %else %do;

  /* SAS Enterprise Guide; CLR 2.0.50727.3620; Microsoft Windows NT 5.1.2600 Service Pack 3

  OR

  StoredProcessService 9.2; JVM 1.6.0_16; Windows Server 2008 (amd64) 6.1 */

  %put Stored Process °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°;

  %STPBEGIN

  %end;

%mend conditionalstpbegin;

%conditionalstpbegin;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 5 replies
  • 2576 views
  • 6 likes
  • 3 in conversation