Your SAS programs, embedded in web apps and elsewhere

One procedure called by another

Reply
Frequent Contributor
Posts: 115

One procedure called by another

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.
SAS Super FREQ
Posts: 8,743

Re: One procedure called by another

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
Frequent Contributor
Posts: 115

Re: One procedure called by another

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.
SAS Super FREQ
Posts: 8,743

Re: One procedure called by another

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
Ask a Question
Discussion stats
  • 3 replies
  • 253 views
  • 0 likes
  • 2 in conversation