<?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: How to create a CSV file from client side , by calling server STP in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-CSV-file-from-client-side-by-calling-server-STP/m-p/767007#M243102</link>
    <description>Yes, we are supposed to use SAS BIWS , The requirement is to use to store procedure to create the CSV file from  input data received from the  client (such as Curl,soap API , or even sas from above client example)&lt;BR /&gt;&lt;BR /&gt;-&amp;gt; can you guide me how to check the webserver logs to analyse internal server error (Http:500) , i couldn't see much details about the error when executing the client program)</description>
    <pubDate>Fri, 10 Sep 2021 07:23:43 GMT</pubDate>
    <dc:creator>learn_SAS_23</dc:creator>
    <dc:date>2021-09-10T07:23:43Z</dc:date>
    <item>
      <title>How to create a CSV file from client side , by calling server STP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-CSV-file-from-client-side-by-calling-server-STP/m-p/766783#M243037</link>
      <description>&lt;P&gt;Hello Team ,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to create a CSV file by calling server side Storeprocedure&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Server side STP :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%global param1 ;&lt;BR /&gt;%global status output_1 ;&lt;BR /&gt;options minoperator mindelimiter=' ';&lt;BR /&gt;%let datestamp=%sysfunc(translate(%sysfunc(today(),yymmdd10.),_,-));&lt;BR /&gt;%let Tgt_File=/home/ user/log_&amp;amp;datestamp..csv ;&lt;/P&gt;
&lt;P&gt;data STATUS_file;&lt;BR /&gt;format status $5.;&lt;BR /&gt;format status_Message $200.;&lt;/P&gt;
&lt;P&gt;%if (%quote(&amp;amp;param1.) in A B C D) %then %do;&lt;BR /&gt;%let status=OK;&lt;BR /&gt;%let output_1 =%quote(Testavailable;&amp;amp;param1.);&lt;BR /&gt;data File_out;&lt;BR /&gt;log_1="&amp;amp;output_1.";&lt;BR /&gt;run;&lt;BR /&gt;data _null_;&lt;BR /&gt;set File_out;&lt;BR /&gt;file "&amp;amp;Tgt_File" dsd MOD ;&lt;BR /&gt;put (_all_) (+0) ;&lt;BR /&gt;run;&amp;nbsp;&lt;BR /&gt;%end;&lt;BR /&gt;%else %do;&lt;BR /&gt;%let status=Error;&lt;BR /&gt;%let status_Message=%quote(Invalid input parameters "&amp;amp;param1.");&lt;BR /&gt;%end; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;=status &amp;amp;=output_1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Client side Program : when we are trying to call the store procedure&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;filename inputf temp;&lt;BR /&gt;filename outputf temp;&lt;BR /&gt;%let input_file = %sysfunc(pathname(inputf));&lt;BR /&gt;%let output_file = %sysfunc(pathname(outputf));&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;file "&amp;amp;input_file.";&lt;BR /&gt;put '&amp;lt;Test_file_STP&amp;gt;';&lt;BR /&gt;put '&amp;lt;parameters&amp;gt;';&lt;BR /&gt;put '&amp;lt;param1&amp;gt;A&amp;lt;/param1&amp;gt;';&lt;BR /&gt;put '&amp;lt;/parameters&amp;gt;';&lt;BR /&gt;put '&amp;lt;/Test_file_STP&amp;gt;';&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;/* Disable certificate use */&lt;BR /&gt;options set = SSLREQCERT "NEVER";&lt;BR /&gt;proc http&lt;BR /&gt;method="POST"&lt;BR /&gt;url="&lt;A href="https://exampleurl.net:0000/SASBIWS/rest/storedProcesses/Test_file_STP" target="_blank"&gt;https://exampleurl.net:0000/SASBIWS/rest/storedProcesses/Test_file_STP&lt;/A&gt;"&lt;BR /&gt;in=inputf &lt;BR /&gt;out=outputf &lt;BR /&gt;WEBUSERNAME="C_Username"&lt;BR /&gt;WEBPASSWORD="C_password"&lt;BR /&gt;AUTH_BASIC;&lt;BR /&gt;DEBUG level=3; /* Add debugging information to log */&lt;BR /&gt;headers "Content-Type"="application/xml";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;expected result :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it should create a file in desired location&lt;/P&gt;
&lt;P&gt;and send response as below&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;test_file_STPResponse&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;test_file_STPResult&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;Parameters&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;status&amp;gt;OK&amp;lt;/status&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;output_1&amp;gt;Testavailable;A&amp;lt;/output_1&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/Parameters&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/test_file_STPResult&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/test_file_STPResponse&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when we run the client program doesn't returns expected result , it throws&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTTP Status 500 – Internal Server Error , instead of expected result&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 08:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-CSV-file-from-client-side-by-calling-server-STP/m-p/766783#M243037</guid>
      <dc:creator>learn_SAS_23</dc:creator>
      <dc:date>2021-09-09T08:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a CSV file from client side , by calling server STP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-CSV-file-from-client-side-by-calling-server-STP/m-p/766805#M243046</link>
      <description>&lt;P&gt;Is there a reason you are using BIWS?&amp;nbsp; As you can see, it involves some security issues, such as embedded passwords and disabled certificates in your case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just create a regular STP and call it using PROC STP - here's an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let appLoc=/Public/app;  /* Metadata or Viya Folder per SASjs config */

/* compile macros (can also be downloaded &amp;amp; compiled seperately) */
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
%inc mc;

/* create an STP */ 
filename ft15f001 temp;
parmcards4;
  /* write a file to the file system */
  data _null_;
    file "/tmp/dc/example.txt";
    /* write a parameter sent from the client */
    put "&amp;amp;myparam";
  run;
;;;;
%mp_createwebservice(path=&amp;amp;appLoc/example,name=makefile)

/* now call the STP with a param */
proc stp program="&amp;amp;apploc/example/makefile";
  inputparam myparam="Hello, file!";
run;
 
/* check the file was created */
data _null_;
  infile "/tmp/dc/example.txt";
  input;
  list;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AllanBowe_0-1631182549144.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63423iDA9AFAEA63DAA2DF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AllanBowe_0-1631182549144.png" alt="AllanBowe_0-1631182549144.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following macro is also helpful for testing SAS web services (on both SAS 9 and Viya):&amp;nbsp;&amp;nbsp;&lt;A href="https://core.sasjs.io/mp__testservice_8sas_source.html" target="_blank"&gt;https://core.sasjs.io/mp__testservice_8sas_source.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case, I would recommend examining the web server logs to further understand the cause of your internal server error.&amp;nbsp; If you are looking to compile and deploy Stored Processes as web services, you could also look at &lt;A href="https://cli.sasjs.io" target="_blank"&gt;https://cli.sasjs.io&lt;/A&gt;&amp;nbsp;-&amp;gt; it provides DevOps for SAS Apps as well as a mechanism for documenting and testing your services, jobs &amp;amp; macros.&amp;nbsp; More info here:&amp;nbsp;&amp;nbsp;&lt;A href="https://sasjs.io/resources/" target="_blank"&gt;https://sasjs.io/resources/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 10:16:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-CSV-file-from-client-side-by-calling-server-STP/m-p/766805#M243046</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-09-09T10:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a CSV file from client side , by calling server STP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-CSV-file-from-client-side-by-calling-server-STP/m-p/767007#M243102</link>
      <description>Yes, we are supposed to use SAS BIWS , The requirement is to use to store procedure to create the CSV file from  input data received from the  client (such as Curl,soap API , or even sas from above client example)&lt;BR /&gt;&lt;BR /&gt;-&amp;gt; can you guide me how to check the webserver logs to analyse internal server error (Http:500) , i couldn't see much details about the error when executing the client program)</description>
      <pubDate>Fri, 10 Sep 2021 07:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-CSV-file-from-client-side-by-calling-server-STP/m-p/767007#M243102</guid>
      <dc:creator>learn_SAS_23</dc:creator>
      <dc:date>2021-09-10T07:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a CSV file from client side , by calling server STP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-CSV-file-from-client-side-by-calling-server-STP/m-p/767015#M243105</link>
      <description>&lt;P&gt;Just to throw another option into the mix - we recently open sourced our (Analytium) &lt;A href="https://sas9api.io" target="_self"&gt;sas9 REST API&lt;/A&gt; - it's available here on github:&amp;nbsp;&lt;A href="https://github.com/analytium/sas9api" target="_blank"&gt;https://github.com/analytium/sas9api&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It provides REST endpoints for all manner of SAS functions such as listing libraries, fetching datasets, listing users &amp;amp; groups etc.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Sep 2021 08:52:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-CSV-file-from-client-side-by-calling-server-STP/m-p/767015#M243105</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-09-10T08:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a CSV file from client side , by calling server STP</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-CSV-file-from-client-side-by-calling-server-STP/m-p/767065#M243132</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/225493"&gt;@learn_SAS_23&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;As I understand it, a file will be server to the server and this files has to be saved&amp;nbsp; as a csv file at the desired location.. This has to be performed using webservice and stored procedure.&lt;BR /&gt;Please have a look at the following.&lt;BR /&gt;1.&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Stored-Processes/Uploading-a-file-through-an-html-form/td-p/203124" target="_blank"&gt;https://communities.sas.com/t5/SAS-Stored-Processes/Uploading-a-file-through-an-html-form/td-p/203124&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2.&lt;A href="https://documentation.sas.com/doc/en/itechcdc/9.4/stpug/p0jqbnv7miosidn1xw3tqe3f0hv0.htm#n0dye76j76rqdbn1aqkyskrpn5jb" target="_blank"&gt;https://documentation.sas.com/doc/en/itechcdc/9.4/stpug/p0jqbnv7miosidn1xw3tqe3f0hv0.htm#n0dye76j76rqdbn1aqkyskrpn5jb&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Sep 2021 16:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-CSV-file-from-client-side-by-calling-server-STP/m-p/767065#M243132</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2021-09-10T16:14:26Z</dc:date>
    </item>
  </channel>
</rss>

