Creating and Registering a SAS Stored Process - SAS BI
by Vinod M
Last modified: April 24th 2019
Creating a Stored Process
Beginning with version 3, sas enterprise guide is the preferred method for working with stored processes because it provides the ability to create, register, and test stored processes from one interface.
SAS ETL Studio also provides a point-and-click interface for creating and registering stored processes.
Stored processes must be .sas file (or PDS members on z/OS) in SAS®9.
If you want to execute an SCL or SOURCE catalog entry, you must write a wrapper.sas program that uses PROC DISPLAY or %include to execute the entry. The SCL list of parameter values familiar to SAS/IntrNet SCL developers is not created automatically when using PROC DISPLAY, so you must use GLOBAL macro variables to access input parameters.
Stored processes can be created and registered manually by
1. writing the code in the SAS Windowing Environment (SAS Display Manager), or a text editor
2. creating the metadata describing the stored process using the SAS Management Console.
Manually Creating a Stored Process
There are three basic steps for manually creating a stored process:
Step 1 – Start with an existing, tested SAS program.
Step 2 – Add the stored process macros.
Step 3 – Register the stored process.
Step1: The SAS Program
Before creating a stored process, make sure that the SAS program it is based on is tested thoroughly.
If the program accesses a SAS data library with a hard-coded path, the MLE (Metadata Libname Engine) can be used to specify the LIBNAME statement if the library is registered in the metadata repository.
When you assign a libref in your metadata, using the LIBNAME statement, there is an advanced option that allows you to identify that the library is preassigned. If you select that option, you can leave the LIBNAME statement out all together, as long as the stored process server has the METAAUTOINIT option specified as an object spawner parameter. The default is set to NOMETAAUTOINIT.
METAAUTOINIT Specifies whether the IOM server should connect back to the SAS Metadata Server during startup in order to obtain additional configuration information such as object server parameters and preassigned libraries. When METAAUTOINIT is specified, the server uses the provided META* options to connect to the SAS Metadata Server. With NOMETAAUTOINIT, IOM server startup does not connect back to the SAS Metadata Server.
Step2: The Stored Process Macros
1. Use the %GLOBAL statement to identify any macro variables used in the original program. These macro variables will be removed and used as stored process input parameters.
2. The program continues with a standard comment (*ProcessBody;) that initiates input parameter processing, if any exist.
3. The %STPBEGIN and %STPEND macros provide the environment needed for a SAS program to run as a stored process.
4. The %STPBEGIN macro initializes the Output Delivery
System (ODS) to generate output from the Stored Process.
5. The %STPEND macro terminates ODS processing and completes delivery of the output to the client or other destinations. The macros must be used as a matched pair.
Parameters are initialized differently for the stored process server and the workspace server. The stored process server sets parameter values before the stored process begins to execute. This means the first line of code in the stored process can access any input parameter macro variable. The workspace server does not set input parameters into macro variables until it reaches a comment line in the stored process.
A stored process that does not contain the comment line will never receive input parameters when executed on a workspace server.
It is recommended that you begin all stored processes (regardless of the server types) with %global declarations for all of your input parameters, followed by the *ProcessBody; comment.
Step3: Registering the Stored Process
The Stored Process Manager Plug-In in sas management console, is used to provide the metadata to register the stored process.
1. name, description, and keywords
2. location of the source code
3. server where the stored process will run
4. any input parameters
5. output options.
Creating and Registering a Stored Process
This demonstration shows how to manually create and register a stored process using an existing SAS program.
1. Start a SAS Display Manager session using Start Ð All Programs Ð SAS Ð BIArchitecture Ð Start SAS.
This shortcut uses some of the same configuration files as your stored process server, so it provides a similar environment for testing. A benefit of this is that the Orion formats are already defined to this SAS session. If you invoke SAS outside of this environment, you receive format errors when you run this code.
2. Copy the following program in to the Enhanced Editor and submit it.
The program above is stored in:
3. Verify that there are no ERROR messages in the log and that the program produced the desired output.
4. Update the program with the stored process macros and remove the %LET statement.
5. Select File Ð Save As and save the updated program to
The directory, StoredProcesses, does not exist and must be created.
Explore SAS BI Sample Resumes! Download & Edit, Get Noticed by Top Employers!Download Now!
Register the New Stored Process Program
6. Start SAS Management Console by selecting Start Ð All Programs Ð SAS Ð SAS Management Console. Choose the BI Architecture metadata profile and username and password provided by the instructor.
7. Locate the Stored Process Manager and select New Folder from the pop-up menu.
The folder in the metadata repository is only a logical way to organize the stored process metadata. The physical programs are stored in a folder on the file system.
8. Enter Training for the Name field and Stored Process programs for the SAS 9.1 training course for the Description.
Select to create the new folder.
9. Right-click the new folder Training and select New Stored Process.
10. Specify Orion Customer List for the Name field. Specify an appropriate description and keywords, if desired.
11. Select to change the SAS Server to SASMain – Logical Stored Process Server.
Make sure you change the SAS server to a stored process server. Stored processes can run on a workspace server, but this example needs the STP server because streaming results is the goal.
12. Select to add a new Source Repository. This opens the Manage Source Repositories window.
A Source Repository is not the same thing as a metadata repository. The Source Repository is the physical location where SAS programs are stored. You first need to allocate a storage location that your servers can access to hold your stored processes. This storage location, or repository, is implemented as a file system directory with the stored processes instances represented as files, by name, with a .sas extension if appropriate for the file system.
14. Specify C:WorkshopwinsassbiovrStoredProcesses for the Location field and A directory for stored processes in the SAS 1 training class for the Description field.
Select to return to the Manage Source Repositories window.
Select to return to the Manage Source Repositories window.
15. Selectto change the Source repository to
16. Type customerlist.sas for the Source file field.
17. Selectto change the Output field to Streaming.
Double-check the settings of this window carefully. It is easy to make a mistake in this window. If you misspell any of the names or choose the wrong options, your stored process will not work, and the problem can be hard to debug later.
18. Select to add a parameter to the stored process.
19. Set the following parameters:
a. Specify Number of Records for the Label field.
b. Specify num for the SAS variable name field.
c. Specify Number of records to print for the Description field.
d. Select Required to make this a required parameter.
e. Change the Type to Integer.
F. Specify 20 for the Default value field.
Select to save the properties.
The SAS variable name must match the name of the macro variable in the SAS program.
The new parameter for the number of records is displayed:
The new stored process is now visible in the Training