BookmarkSubscribeRSS Feed
Jaime
Fluorite | Level 6
Hello all,

Anyone know how to make a stored procedure call another stored procedure? This is without any forms of links.
The procedure completes then calls a second one based on the results.
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
Hi:
Without calling a Stored Process via links, the type of processing you describe sounds more like SAS Macro facility conditional logic. Consider that I might have these 2 macro programs stored in a location accessible to the stored process server or the workspace server:
[pre]
%main_task(something=, other=);

%cond_task(parm1=, parm2=);
[/pre]

It doesn't really matter what these 2 macro programs do. Now, let's imagine a third macro program that ALWAYS calls %MAIN_TASK and then conditionally calls %COND_TASK. Let's also imaging that %MAIN_TASK macro creates a macro variable called &SWITCH with a value of Y (to run %COND_TASK) or N (to bypass %COND_TASK):

[pre]
%macro runmac;
%global SWITCH ;
** always run MAIN_TASK macro which sets global macro variable &SWITCH to Y or N;

%maintask(something=aaa, other=bbb);

** now, conditionally run %COND_TASK, which creates WORK.WOMBAT and print the dataset;
%if %upcase(&switch) = Y %then %do;
%cond_task(parm1=xxx,parm2=yyy);

proc print data=work.wombat;
title "Printed because SWITCH=&switch";
run;
%end;

%mend runmac;
[/pre]

Now, assuming that all 3 macro programs are in an AUTOCALL macro library, that is accessible to the servers, you could have a stored process like this:
[pre]
*ProcessBody;
%stpbegin;

%runmac;

%stpend;
[/pre]

There is a location under the LEV1 directory on your installation platform which is the location for SAS macro programs. If you put your macro programs there, you should be able to call them using %macpgm invocation syntax. See this note about AUTOCALL locations:
http://support.sas.com/kb/32/231.html

Also, see this previous post for some more information:
http://support.sas.com/forums/thread.jspa?threadID=5058

cynthia
Jaime
Fluorite | Level 6
This is actually for a web application used in the Information Delivery Portal.

I first trigger a stored procedure that collects the prompt values using the prompt wizard in EG. Once the user clicks RUN I want the stored process to display an html page stating the user inputs have been received and they will receive and email shortly with the report they requested.
This page would also trigger another stored process, in the background, that would generate the report and email it to the user.
Cynthia_sas
SAS Super FREQ
Ah.... it is entirely do-able within the context of the IDP. If the HTML page that you create contains an HTML form, then the form <FORM> ACTION attribute can be a call to SASStoredProcess/do .... making a call to the SPWA (Stored Process Web App) to execute the second stored process.

Check the IDP samples for some FORM examples.

cynthia

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 1074 views
  • 0 likes
  • 2 in conversation