Macros for SAS Application Developers
https://github.com/sasjs/core
mm_createstp.sas File Reference

Create a type 1 Stored Process (9.2 compatible) More...

Go to the source code of this file.

Detailed Description

This macro creates a Type 1 stored process, and also the necessary PromptGroup / File / TextStore objects. It requires the location (or uri) for the App Server / Directory / Folder (Tree) objects. To upgrade this macro to work with type 2 (which can embed SAS code and is compabitible with SAS from 9.3 onwards) then the UsageVersion should change to 2000000 and the TextStore object updated. The ComputeServer reference will also be to ServerContext rather than LogicalServer.

This macro is idempotent - if you run it twice, it will only create an STP once.

Usage (type 1 STP):

%mm_createstp(stpname=MyNewSTP
  ,filename=mySpecialProgram.sas
  ,directory=SASEnvironment/SASCode/STPs
  ,tree=/User Folders/sasdemo
  ,outds=work.uris)

If you wish to remove the new STP you can do so by running:

data _null_;
  set work.uris;
  rc1 = METADATA_DELOBJ(texturi);
  rc2 = METADATA_DELOBJ(prompturi);
  rc3 = METADATA_DELOBJ(fileuri);
  rc4 = METADATA_DELOBJ(stpuri);
  putlog (_all_)(=);
run;

Usage (type 2 STP):

%mm_createstp(stpname=MyNewType2STP
  ,filename=mySpecialProgram.sas
  ,directory=SASEnvironment/SASCode/STPs
  ,tree=/User Folders/sasdemo
  ,Server=SASApp
  ,stptype=2)
Parameters
stpname=Stored Process name. Avoid spaces - testing has shown that the check to avoid creating multiple STPs in the same folder with the same name does not work when the name contains spaces.
stpdesc=Stored Process description (optional)
filename=the name of the .sas program to run
directory=The directory uri, or the actual path to the sas program (no trailing slash). If more than uri is found with that path, then the first one will be used.
tree=The metadata folder uri, or the metadata path, in which to create the STP.
server=The server which will run the STP. Server name or uri is fine.
outds=The two level name of the output dataset. Will contain all the meta uris. Defaults to work.mm_createstp.
mDebug=set to 1 to show debug messages in the log
stptype=Default is 1 (STP code saved on filesystem). Set to 2 if source code is to be saved in metadata (9.3 and above feature).
minify=set to YES to strip comments / blank lines etc
frefin=fileref to use (enables change if there is a conflict). The filerefs are left open, to enable inspection after running the macro (or importing into an xmlmap if needed).
frefout=fileref to use (enables change if there is a conflict)
repo=ServerContext is tied to a repo, if you are not using the foundation repo then select a different one here
Returns
outds dataset containing the following columns:
  • stpuri
  • prompturi
  • fileuri
  • texturi

SAS Macros

Related Macros

Version
9.2
Author
Allan Bowe

Definition in file mm_createstp.sas.