07-23-2012 04:39 AM
Other option you can do is to create a sas file wherein you put all the codes that you want to be executed prior to running stored procs.
After that you need to go to SMC, on the properties->options of the stored procses definition and add the -autoexec parameter on the execution command.
Just curious, what are you planning to put on the autoexec which needs to execute prior to your stored processes? libnames? admin table logging?
Hope this helps,
07-23-2012 08:46 AM
I knew you could specify an autoexec at the server level, but are you saying that you can specify an autoexec at the stored process level (i.e. a different autoexec for different stored processes)? I've been hoping to do that, but haven't been able to see how it could be done (I'm not an admin on the server, so may not be seeing all that is possible). So now I just start a stored process definition by %including an autoexec.
I'm not seeing where I can specify an autoexec for a stored process in SMC:
08-15-2012 07:52 AM
The one I know and was saying on my previous post is a universal one. Meaning that for everytime a stored process is executed, it executes the autoexec file specified first. I was also hoping that they have a feature similar on what you want.
Sorry, but with your requirement I think there's currently no way to have different autoexecs depending on the stored proc to execute except for your current approach which is the use of %include.
07-25-2012 04:42 AM
> "Just curious, what are you planning to put on the autoexec which needs to execute prior to your stored processes? libnames? admin table logging?"
I wanted to define macros, formats and a template
I figured how to store the macros in a sasmacr catalog but the problem remains the same, I have to declare the sasmstore at the beginning of every project flow or stored process:
"options mstored sasmstore=common ;"
And since this is locking the catalog, I now also have to use this hack at the end of every project flow or stored process:
/* HACK TO REALEASE LOCK ON MACROS.SASMACR.CATALOG */
* get the current value of the SASMSTORE option ;
* assign a temp libref to the path of the work library ;
libname temp "%sysfunc(pathname(work))" access=temp;
* assign the temp library to the SASMSTORE option ;
options mstored sasmstore=temp;
* compile and store dummy macro ;
%macro foo /store;
* reset the SASMSTORE option to the original value ;
options mstored sasmstore=&mstorelib;
would like not having to copy paste it everywhere...
08-15-2012 08:07 AM
If that's the case for you then you can try what I was saying assuming that you want that piece of code to be executed for all stored procs.
1. Put that piece of code on a separate .sas file. (Ex. myautoexec.sas)
2. Under SMC, Go to Server Manager -> SASMain -> Logical Stored Process Server, right click properties on the innermost one.
3. Under the Options tab, you should see the Command item there, I think by default this is the value there:
sas -config "C:\SAS\MyPlan\Lev1\SASMain\StoredProcessServer\sasv9_StorProcSrv.cfg"
then add here your autoexec file, so it would go something like this:
sas -config "C:\SAS\MyPlan\Lev1\SASMain\StoredProcessServer\sasv9_StorProcSrv.cfg" - autoexec <path>\myautoexec.sas
4. Restart your SAS Services, then try to check run a stored proc and see it works.
Hope this helps,