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.

BASUG is hosting free webinars ! Next up: Art Carpenter on February 28 at noon ET. Register now at the Boston Area SAS Users Group event page: 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-2024.png

 

Secure your spot at the must-attend AI and analytics event of 2024: SAS Innovate 2024! Get ready for a jam-packed agenda featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events.

 

Register by March 1 to snag the Early Bird rate of just $695! Don't miss out on this exclusive offer. 

 

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