<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Including a stored process from a stored process on the metadata server in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819217#M81878</link>
    <description>&lt;P&gt;Your stored process that is stored on the metadata server can still %include a .sas file that is stored on the OS storage of your SAS server.&amp;nbsp; You might need to work with your admin or a colleague to understand which SAS server your stored process is running on, and where you can store .sas files to be %included by the server.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have EG or Studio, it might be easier to use those and see what file storage locations you can see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All of my stored processes are stored in metadata, but the source code is typically just a %include statement that points to a .sas file sitting on our server.&amp;nbsp; So the STP is just a wrapper.&amp;nbsp; My DI Studio jobs are the same thing, just a single node which %includes a .sas file.&lt;/P&gt;</description>
    <pubDate>Mon, 20 Jun 2022 22:15:00 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2022-06-20T22:15:00Z</dc:date>
    <item>
      <title>Including a stored process from a stored process on the metadata server</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819202#M81877</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a series of business case testing that are done across 12-20 stored processes. Each of these have the same data gathering logic (with some filter variables, and different inputs), and then a section with each of the specific tests. I would like to take the data gathering logic out and move it to a stored process that is called by each test so that I only need to update it in one place.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Base-Data&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The Data gathering step runs a series of ProcSQL steps creating the base datasets for the tests. It does not output anything to a report or screen.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Test processes&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The tests run simple procSQL tests, and output ODS Excel objects (we run these from Excel using the office plugin).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Here is an example test:&lt;/P&gt;&lt;PRE&gt;/*Classes to Check*/  
%let Classes = %NRSTR("PS","PT","PH");  

/**************************************************************************************  
Include the Base views that all of the tests use  
***************************************************************************************/  
%include "./AppointmentAuditBaseViews.sas" /source2;  
 
/*######################## &lt;BR /&gt;Check to see if the right dues are setup &lt;BR /&gt;###########################*/ &lt;BR /&gt;proc sql; &lt;BR /&gt;options compress=yes; &lt;BR /&gt;create table DuesNotSetup as &lt;BR /&gt;SELECT * FROM WORK.JobsWithDeductions WHERE &lt;BR /&gt;AllDeductions not like "%DPE%" ; &lt;BR /&gt;run; &lt;BR /&gt;&lt;BR /&gt;proc sql; insert into ReportSummary SET Title="Dues not Setup", Results =(select count(D.CKey) from DuesNotSetup D); quit; &lt;BR /&gt;ods excel; &lt;BR /&gt;title j=left "Dues not Setup"; &lt;BR /&gt;footnote2 j=center color=blue &lt;BR /&gt;height=10pt "&amp;amp;sysdate9"; &lt;BR /&gt;proc report style= [just=left] data=WORK.DuesNotSetup; &lt;BR /&gt;run; &lt;BR /&gt;ods excel close; 
/*Summary report to count how many tests are left*/  
ods excel;  
title j=left "Summary";  
footnote2 j=center color=blue  
height=10pt "&amp;amp;sysdate9";  
proc report style= [just=left] data=WORK.ReportSummary;   
run;   
ods excel close;   
  
quit;&lt;/PRE&gt;&lt;P&gt;The problem that I am having is that we store the process on the metadata server, and I cannot figure out how to include a program that is stored on the metadata server, and the system throws an error around the saving of the WORK file if I save it on the drive rather than in metadata.&amp;nbsp;&lt;BR /&gt;Does anyone have any advice?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 20:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819202#M81877</guid>
      <dc:creator>wolowicz</dc:creator>
      <dc:date>2022-06-20T20:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: Including a stored process from a stored process on the metadata server</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819217#M81878</link>
      <description>&lt;P&gt;Your stored process that is stored on the metadata server can still %include a .sas file that is stored on the OS storage of your SAS server.&amp;nbsp; You might need to work with your admin or a colleague to understand which SAS server your stored process is running on, and where you can store .sas files to be %included by the server.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have EG or Studio, it might be easier to use those and see what file storage locations you can see.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All of my stored processes are stored in metadata, but the source code is typically just a %include statement that points to a .sas file sitting on our server.&amp;nbsp; So the STP is just a wrapper.&amp;nbsp; My DI Studio jobs are the same thing, just a single node which %includes a .sas file.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 22:15:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819217#M81878</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-06-20T22:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: Including a stored process from a stored process on the metadata server</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819243#M81879</link>
      <description>&lt;P&gt;Could be done by adding a parameter to the process gathering the data that allows selecting the process to be run afterwards. BUT this is far more difficult than using %include: you have to edit the list of process manually, you can't use the default macros %stpbeginn and %stpend, instead you have to open an ods destination and write the html-code that calls the next process. I am not sure that this will work at all, if the process to be executed has no parameters. Here is an excerpt of the code i wrote some years ago:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;      %local url programmName;
      %let programName = %sysfunc(urlencode(&amp;amp;TargetProcess));
      %let url = %str(https://&amp;amp;_SRVNAME/SASStoredProcess/do);
      %let url = %str(&amp;amp;url?_action=properties,nobanner%nrstr(&amp;amp;_program=)&amp;amp;programName);

      data _null_;
         file _webout;         
         put '&amp;lt;HTML&amp;gt;&amp;lt;HEAD&amp;gt;';
         put '&amp;lt;META HTTP-EQUIV="Refresh" NAME="NULL"';
         put "CONTENT=""0;URL=&amp;amp;url""&amp;gt;";
         put '&amp;lt;/HEAD&amp;gt;';
         put '&amp;lt;BODY&amp;gt;';
         put '&amp;lt;/BODY&amp;gt;';
         put '&amp;lt;/HTML&amp;gt;';
      run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;TargetProcess has the full name (including metadata-path) of the process.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 05:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819243#M81879</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-06-21T05:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: Including a stored process from a stored process on the metadata server</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819292#M81880</link>
      <description>&lt;P&gt;When you say:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;I would like to take the data gathering logic out and move it to a stored process that is called by each test so that I only need to update it in one place.&amp;nbsp;&lt;/BLOCKQUOTE&gt;
&lt;P class="1655810308572"&gt;That sounds to me like the logic (code) should be in a macro, not necessarily a stored process.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P class="1655810308572"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="1655810308572"&gt;It is straight forward to call a macro from a stored process definition.&amp;nbsp; It's more difficult to literally call a stored process from a stored process (I have done it, by having a stored process generate an html frame that displays the URL of the called stored process).&lt;/P&gt;
&lt;P class="1655810308572"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="1655810308572"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 11:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819292#M81880</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-06-21T11:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Including a stored process from a stored process on the metadata server</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819388#M81881</link>
      <description>&lt;P&gt;My macro skills are very very basic. Can you save the Macros to the server as a library or something other than a stored process?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 16:56:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819388#M81881</guid>
      <dc:creator>wolowicz</dc:creator>
      <dc:date>2022-06-21T16:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: Including a stored process from a stored process on the metadata server</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819391#M81882</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/19879" target="_blank" rel="noopener"&gt;&lt;SPAN class=""&gt;Quentin,&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;It's good to know that you are not having issues.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I do the include it seems to be grumpy with a work directory. Maybe its a permissions or file path issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;ERROR: The result package could not be created. The error encountered was:&lt;BR /&gt;ERROR: No files were added to the package because the STP work directory&lt;BR /&gt;(/**/SASWORK/SAS_work54AC000024E2_***********************/SAS_work2D2D000024E2_***********************/2d3f7ee5-b21d-3342-b441-9fa25df3ee70/) is empty.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I have stared out the sensitive stuff.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I change it to stream results, I get an error with characters before starting the output XML.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 17:05:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819391#M81882</guid>
      <dc:creator>wolowicz</dc:creator>
      <dc:date>2022-06-21T17:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Including a stored process from a stored process on the metadata server</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819397#M81883</link>
      <description>&lt;P&gt;The easiest way to to just save the macro as a .sas file sitting somewhere on the server's file system.&amp;nbsp; But you don't need to use a macro, you could also just have a .sas file that you %include.&amp;nbsp; The .sas file would not have all the stored process wrapper stuff (%sptbegin, %stpend, etc.), it would be just the DATA steps or SQL steps you need for the data munging you want to do.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 17:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819397#M81883</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-06-21T17:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Including a stored process from a stored process on the metadata server</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819400#M81884</link>
      <description>&lt;P&gt;I always use streaming results.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For having a stored process that called a child stored process, I had the parent stored process generate a frame, and the URL displayed in the frame was the child stored process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the parent stored process is writing an HTML file to return the the browser.&amp;nbsp; And then at some point it uses PROC ODS TEXT to insert the HTML for the frame to display the child stored process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;      %local frameHTML;
      %let frameHTML=&amp;lt;iframe src="" https://myserver.com:443/SASStoredProcess/do?%nrstr(&amp;amp;_program=)&amp;amp;_metafolder.SomeStoredProcess"" 
                     height="" 100% "" 
                     width="" 100% "" 
                     frameborder="" 0 "" noresize scrolling="" auto ""&amp;gt;Browser must support frames!
                     &amp;lt;/iframe&amp;gt;;

      proc odstext;
        p "&amp;amp;frameHTML";
      run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This was a long time ago, and I'm sure there are MUCH better ways. : )&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 17:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819400#M81884</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2022-06-21T17:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Including a stored process from a stored process on the metadata server</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819401#M81885</link>
      <description>&lt;P&gt;My processes output to Excel directly with ProcReport, so I can't (shouldn't) put HTML and frames in.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 17:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819401#M81885</guid>
      <dc:creator>wolowicz</dc:creator>
      <dc:date>2022-06-21T17:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Including a stored process from a stored process on the metadata server</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819405#M81886</link>
      <description>&lt;P&gt;This worked. I saved it as a file to the server (not as a stored process, but as a "save-as"), then referenced it in the code with an %include. My issues with input and output buffer control all went away.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 18:01:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819405#M81886</guid>
      <dc:creator>wolowicz</dc:creator>
      <dc:date>2022-06-21T18:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Including a stored process from a stored process on the metadata server</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819580#M81887</link>
      <description>&lt;P&gt;I see you're running tests - have you considered using &lt;A href="https://cli.sasjs.io/test/" target="_self"&gt;sasjs test&lt;/A&gt;?&amp;nbsp; This approach pushes all your tests as stored processes, executing them from a local CLI.&amp;nbsp; The approach will also work on Viya, and Base SAS, simply by updating your connection details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Back to your question - normally you can include your stored process using `proc stp`.&amp;nbsp; However, if you are just interested in grabbing the source code, you can also use this macro:&amp;nbsp;&amp;nbsp;&lt;A href="https://core.sasjs.io/mm__getstpcode_8sas.html" target="_blank"&gt;https://core.sasjs.io/mm__getstpcode_8sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are looking for an environment-agnostic macro, there is also this one:&amp;nbsp;&amp;nbsp;&lt;A href="https://core.sasjs.io/mx__getcode_8sas.html" target="_blank"&gt;https://core.sasjs.io/mx__getcode_8sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The test for the above is here!&amp;nbsp;&amp;nbsp;&lt;A href="https://core.sasjs.io/mx__getcode_8sas.html" target="_blank"&gt;https://core.sasjs.io/mx__getcode_8sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 11:52:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Including-a-stored-process-from-a-stored-process-on-the-metadata/m-p/819580#M81887</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2022-06-22T11:52:21Z</dc:date>
    </item>
  </channel>
</rss>

