Home » Stored Processes

Three of the Most Common SAS Stored Process Errors

Submitted by on March 24, 2013 – 9:31 pm One Comment

If you want to learn how to create a stored process at the SAS Global Forum 2013, then make sure you attend the “Building Your First Stored Process” Hands On workshop that Angela and are hosting on Wednesday morning.  We will show you how to build a three different stored process with prompts in under 90  minutes. In the meantime, here are the most common errors that new developers make to help you as you get started.  

Update: It was a fun presentation –  here’s the paper.

Error #1: LIBNAME is Not Assigned

If you develop your stored process code in SAS Enterprise Guide, then the code uses your Connection Profile.  Thus it has access to all of your libraries.  When that code is moved to the stored process, you might find its generates a “LIBNAME not found error”. A best practice is to always add the LIBNAME statement to your stored process.  You can learn more about how the libraries are assigned  in the SAS 9.3 user documentation: “Assigning Libraries“. If you are still confused, I thought the SAS 9.2 documentation had a helpful description of pros and cons here.

You don’t have to read the entire background – just find the library connection you need to make as shown below.  Note: For this example, system library simply means it does not exist in the metadata so you call the library from the file system.

Use the Libname Statement

Error #2: Unexpected or No Results with Macros 

If you have added the %STPBegin and %STPEnd macros in your stored process, then you must ensure the Stored Process Wizard does not add it back. If you have added the macros and the wizard has added the macros, then you see where some interesting results might occur. The worse part of troubleshooting the issue is that it can take several hours with the log to determine the issue. Refer to the “Double, Triple Check Those STP Macros ” post for more help.

STP Macros Options

Error #3: Prompt Always Uses the Same Values

Did your prompt work, but it keeps making the same choice no matter way you select?  For instance, you selected the East region but it returns the West region – no matter how many times you select it? You might want to double-check the code to see if you left the LET statements in it.  Many programmers  test the prompts to ensure they work or create errors to confirm the prompt will fail.  If it’s a large stored process, then you may forget you did it.  That’s worth some more time trying to find why your prompt failed.  

This one has caught me more than once.

SAS Stored Process LET Statement


Learn More about SAS Stored Processes and Prompts

You can learn more tips and tricks for creating, debugging, and using SAS stored processes in the 50 Keys to Learning SAS Stored Processes book. It's a complete guide to SAS stored processes. Check Amazon for best pricing and quick shipping!

Attending SESUG 2015?

If you are planning to attend SESUG 2015 in beautiful Savannah, Georgia on Sept 29 then join me for my talk about data visualization "How to be the MacGyver of Data Visualization"! I'll show you some cool ways to visualize data with SAS Visual Analytics as well as some traps to avoid.

The following two tabs change content below.

Tricia Aanderud

SAS Consultant at Zencos
Tricia Aanderud is a SAS Business Intelligence and Visual Analytics consultant based in Raleigh, NC who works for Zencos Consulting. She has written several books about SAS, presented papers at many SAS conferences, and has over 10 years of SAS programming experience. Contact her for assistance with your next project.

Tags: , , , ,

One Comment »