Where is the SAS code for that stored process?


Stored process code can exist within the metadata itself for version 9.3 (the benefits of which I discussed earlier). But for all other versions (and as a option in version 9.3) the SAS code is  stored as a .sas file within the server's file system (or mapped folder/drive structure). When editing stored process code directly, you need to know where the stored process .sas file resides.

Here are a few places to find that .sas file location. Do you have any other ways?
1. Through the SAS Management Console properties screen, select the Execution tab.

2. Using PROC STP (SAS 9.3)

 options metaserver = 'machine'
 metaport = 8561
 metauser = 'XXXXXXXXXX'
 metapass = XXXXXXXXXX;
 PROC STP PROGRAM='/Projects/Book Examples/12_d_AMOParetoEdits';
 list group=execution;

The output then provides:
NOTE: PROC_STP: ====== Stored Process: /Projects/Book Examples/12_d_AMOParetoEdits ======
NOTE: PROC_STP: ====== Metadata Listing for /Projects/Book Examples/12_d_AMOParetoEdits ======
NOTE: Logical Server: SASApp - Logical Stored Process Server
NOTE: Source Code Repository: C:\SAS\Stp Book
NOTE: Source File: Example_12d_AddInParetoEdits.sas
NOTE: Result Type: Packages No
NOTE: Streaming Yes
NOTE: PROC_STP: ====== End Metadata Listing for /Projects/Book Examples/12_d_AMOParetoEdits ======
NOTE: PROC_STP: ====== Stored Process: /Projects/Book Examples/12_d_AMOParetoEdits Return Status
= 0 ======
NOTE: PROCEDURE STP used (Total process time):
real time 0.63 seconds
cpu time 0.04 seconds

3. By running a metadata call
In the following example, I have a sas program that will pull out a full list of all the stored processes registered in the metadata, each corresponding .sas file and where in the server these physical files reside.

/*insert an options statement here to connect to your metadata server/port.*/
data new(keep=dirname stpname stpcode);
label dirname="Directory Name";
label stpname="Stored Process Name";
label stpcode=".sas File Name";
 length uri name dirname stpuri stpcode stpassn stpname $256;

n=1; nobj=1;
    do while(nobj >= 0); 
        nobj=metadata_getnobj("omsobj:Directory?@Id contains '.'",n,uri);
    put nobj;
        if (nobj < 0) then leave; 
    if Name = "SP Source Directory" then do;
       rc1=1; x=1; 
        do while(rc1>0);
      rc1=metadata_getnasn(uri, "Files", x, stpuri); 
      rc2=metadata_getattr(stpuri, "FileName", stpcode); 
      rc3=metadata_getnasn(stpuri, "AssociatedTransformation", 1, stpassn);
      rc4=metadata_getattr(stpassn, "Name", stpname); 
title 'All Stored Process Locations';
proc print label noobs;

Included below is a screenshot of the resulting report.


About Author

Angela Hall

Senior Technical Architect

Angela offers tips on using the SAS Business Intelligence solutions. She manages a team of SAS Fraud Framework implementers within the SAS Solutions On-Demand organization. Angela also has co-written two books, 'Building BI using SAS, Content Development Examples' & 'The 50 Keys to Learning SAS Stored Processes'.

Related Posts


  1. Pingback: Using METABROWSE to locate and code programs to retrieve metadata

    • Angela Hall

      Thanks D! When adding _action=data in the URL of the SAS Stored Process Web Application for a specific stored process, you can retrieve this same information. Included in the documentation is an example of the "Stored Process Summary Page".

Leave A Reply

Back to Top