Desktop productivity for business analysts and programmers

Creating Stored Process through batch run - Is it possible

Frequent Contributor
Posts: 97

Creating Stored Process through batch run - Is it possible

We have all Stored Process based reports. These SP's are created through EG.

For any change in the EG project we have to create the Sp's and this is time consuming.

Is there any way by which I can create the Stored Processes through command line through a batch program by specifying the project names and other parameters.
Posts: 9,426

Re: Creating Stored Process through batch run - Is it possible

Once you create a Stored Process you do not necessarily need the EG project, anymore, that was used initially to create the stored process.

For example, you create a project that points to PERMLIB.JAN2007 and you create some tasks and some reports. Then you turn that project into a stored process. Let's say you want to reuse that SP for PERMLIB.FEB2007 and PERMLIB.MAR2007 and PERMLIB.APR2007 and so forth.

You do NOT have to redo the project every month or create a new SP for every month. But, you DO have to understand SAS macro variables and how they work inside SPs and assuming that every month's file has the same variable names, and that every month's file is registered in the Metadata. Then, all you have to do is either prompt the user for the month and file name when they execute the SP --or use macro syntax to automatically set the month when you run the SP.

Of course, once you make these changes to the EG-generated code, then you have essentially created something (a .SAS program) that is no longer an EG project -- but since it was originally created from an EG project, you should be comfortable with what the output is going to look like enough so that you want to essentially turn the code from that project into a re-usable set of code steps that can be run every month.

In my view, you do not need to create the SP in batch, so much as you need to understand a bit more about SAS macro syntax, how SAS macro variables work and how a SAS macro program can be used to actually generate your changed code every month.

That is too big a set of questions to answer here. There have been many examples of using a SAS macro program to generate self-changing code in a stored process posted to the forums; however, it would probably be better, and less error-prone, for you to get help from Tech Support with your exact problem and what you need to exactly do, rather than getting piece-by-piece and question-by-question advice here. The fact is that the design of your macro code and macro program may change from somthing originally tested with simple substitution to more complex code that uses macro conditional logic to generate chunks of your final stored process. And the kind of SP that you develop may have to change depending on the client application from which the SP will be run and the kind of final code you want have executed based on the user's input (or the kind of automatic code you want to have executed based on some other condition).

For an introduction to SAS Macro processing in general, refer to: or a paper, entitled "Understanding Why Your Macros Don't Work" from this site: .

For an overview of "manual" (outside EG) program conversion to an SP, refer to the presentation:
Adapting Your Programs to the SAS®9 Paradigm available for download from: or
this other SGF paper on ODS Options and Stored Processes, available from this site: or
this SGF paper, a SAS Stored Process Case Study .

To find out how to contact Tech Support, refer to:

Trusted Advisor
Posts: 2,127

Re: Creating Stored Process through batch run - Is it possible

Posted in reply to Cynthia_sas
Thanks Cynthia, that was most informative (even to those of us who haven't used stored processes).

Grasshopper, once you digest Cynthia's comments, you can go over to the SAS Forum for stored processes to really get into the nitty-gritty:
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation