BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am converting a program from a language called FOCUS to an eventual EG Stored Process. The current program has a lot of parameters that must be entered before executing.

My question: Can a stored process have more than one screen of parameters? If so, how would that be done?

Second question: Can a stored process call another stored process?
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi!
When you define the parameters, you have the option to set parameter groups in EG -- each parameter group gets it's own "tab" in the interface in EG and MS Office. So if you consider each "tab" to be like a screen, then you don't have to worry about coding the screens -- just make logical parameter groups and put parameters into them. In EG you can make the parameters and then make the groups and drag and drop the parameters into groups. In SAS Mgt Console, you have to define the groups first and then place the parameters in the right group when you click to create it.

I would not try to have a stored process call another stored process. If I had code that needed to be executed conditionally, I would put the conditional code into macro programs that lived in an AUTOCALL library.

So let's assume that I have some weekly report code and some daily report code and based on a parameter value in the SP, the users can choose whether to run the weekly report or the daily report. I can make a macro program (a black box right now) called %weekly; for the weekly report and %daily; for the daily report -- and in my main SP, I'm going to define a parameter called REPTYPE that will allow them to select either WEEKLY or DAILY

Assuming that those macro programs are stored in the AUTOCALL macro location that my BI Platform installation knows about, then I can do this in my SP:
[pre]
**** start of SP program code -- call this DOREPT.SAS;
**** register as DOREPT stored process with 1 parameter REPTYPE;
**** Output type is STREAMING;

%global reptype;

libname mylib .....;

%macro testparm;
%if %upcase(&reptype) = WEEKLY %then %do;
%weekly;
%end;
%else %if %upcase(&reptype) = DAILY %then %do;
%daily;
%end;
%mend;

%stpbegin;
%testparm;
%stpend;

**** end of SP program code;
[/pre]


The macro program that is INSIDE my DOREPT.SAS program is defined "in-stream" but, it too could be an AUTOCALL macro. I didn't want to make too many black boxes! I generally keep my macro definitions (%macro/%mend) outside of
%stpbegin/%stpend -- just to keep my housekeeping and debugging easier to keep track of.

Only the call to the %TESTPARM macro needs to be inside %STPBEGIN;/%STPEND; because it is the invocation or %WEEKLY or %DAILY that will really produce my output.

If you are going to do a LOT of conditional processing in your stored process, then you'll end up needing to know about the SAS Macro facility and how to write and use macro programs effectively. The parameters that you set for your stored processes are passed to either the Workspace server or the Stored Process server as Global Macro variables that live in the Global Symbol Table on the server.

Guess who can help you figure out the right location for AUTOCALL macros on your BI installation and/or help you with macro syntax??? Tech Support 😉

cynthia
deleted_user
Not applicable
Thanks so much for the hints, 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
  • 2 replies
  • 676 views
  • 0 likes
  • 2 in conversation