<?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: Upload file with sas job execution and save file on server in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Upload-file-with-sas-job-execution-and-save-file-on-server/m-p/782899#M249588</link>
    <description>&lt;P&gt;My team have built two free / semi-free tools that can help you with this particular task:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;1) File uploader.&amp;nbsp; A SASjs web app that lets you upload any file to any location on a Viya server -&amp;nbsp;&lt;A href="https://github.com/sasjs/fileuploader" target="_blank"&gt;https://github.com/sasjs/fileuploader&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Data Controller.&amp;nbsp; Free for 5 users, you can drag &amp;amp; drop excel files directly into any (matching) SAS table.&amp;nbsp; &lt;A href="https://datacontroller.io" target="_blank"&gt;https://datacontroller.io&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Nov 2021 12:38:31 GMT</pubDate>
    <dc:creator>AllanBowe</dc:creator>
    <dc:date>2021-11-29T12:38:31Z</dc:date>
    <item>
      <title>Upload file with sas job execution and save file on server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Upload-file-with-sas-job-execution-and-save-file-on-server/m-p/781897#M249214</link>
      <description>&lt;P&gt;Hello to all,&lt;BR /&gt;I created a sas job execution that is called up by users through visual analytics to give them the opportunity to update excel files. &lt;BR /&gt;At the moment I can't physically save the file to a path on my server.&lt;BR /&gt;my code:&lt;/P&gt;
&lt;P&gt;options validvarname=any validmemname=extend;&lt;BR /&gt;%macro read_uploaded_files;&lt;BR /&gt;data _null_;&lt;BR /&gt;%local i n;&lt;/P&gt;
&lt;P&gt;%put Total files: &amp;amp;_WEBIN_FILE_COUNT;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;/* Read the file in to SAS. Comment out for testing. */&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;filename upload filesrvc parenturi="&amp;amp;SYS_JES_JOB_URI" &lt;BR /&gt;name="&amp;amp;_WEBIN_FILENAME" &lt;BR /&gt;contenttype="&amp;amp;_WEBIN_CONTENT_TYPE"; &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options validvarname=any validmemname=extend;&lt;/P&gt;
&lt;P&gt;%put file ------&amp;gt;&amp;amp;_WEBIN_FILENAME.;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;ods excel file="path/&amp;amp;_WEBIN_FILENAME.";&lt;/P&gt;
&lt;P&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%read_uploaded_files;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hello to all,&lt;BR /&gt;I created a sas job execution that is called up by users through visual analytics to give them the opportunity to update excel files. &lt;BR /&gt;At the moment I can't physically save the file to a path on my server.&lt;BR /&gt;my code:&lt;/P&gt;
&lt;P&gt;options validvarname=any validmemname=extend;&lt;BR /&gt;%macro read_uploaded_files;&lt;BR /&gt;data _null_;&lt;BR /&gt;%local i n;&lt;/P&gt;
&lt;P&gt;%put Total files: &amp;amp;_WEBIN_FILE_COUNT;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;/* Read the file in to SAS. Comment out for testing. */&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;filename upload filesrvc parenturi="&amp;amp;SYS_JES_JOB_URI" &lt;BR /&gt;name="&amp;amp;_WEBIN_FILENAME" &lt;BR /&gt;contenttype="&amp;amp;_WEBIN_CONTENT_TYPE"; &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;options validvarname=any validmemname=extend;&lt;/P&gt;
&lt;P&gt;%put file ------&amp;gt;&amp;amp;_WEBIN_FILENAME.;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;ods excel file="path/&amp;amp;_WEBIN_FILENAME.";&lt;/P&gt;
&lt;P&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%read_uploaded_files;&lt;BR /&gt;I tried with the instruction:&lt;BR /&gt;ods excel file = "path / &amp;amp; _ WEBIN_FILENAME.";&lt;BR /&gt;but the file that is saved on the server is empty.&lt;BR /&gt;Any suggestions?&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 10:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Upload-file-with-sas-job-execution-and-save-file-on-server/m-p/781897#M249214</guid>
      <dc:creator>dipand</dc:creator>
      <dc:date>2021-11-23T10:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file with sas job execution and save file on server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Upload-file-with-sas-job-execution-and-save-file-on-server/m-p/781907#M249219</link>
      <description>&lt;P&gt;Some pointers to help you get an answer faster&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;When providing code please use the Insert SAS Code icon below the &lt;STRONG&gt;Body&lt;/STRONG&gt;&amp;nbsp;subtitle:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AMSAS_0-1637666548491.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66031i6FB99CD01469D9D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AMSAS_0-1637666548491.png" alt="AMSAS_0-1637666548491.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;Provide the SAS Log, use the insert code icon:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AMSAS_1-1637666647436.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66032iAB0E4FA3E66CCBE6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AMSAS_1-1637666647436.png" alt="AMSAS_1-1637666647436.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;For your specific case, I'd suggest you start by&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;removing all the macro code&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;simplify the code to the bare minimum to update and save a single excel file&amp;nbsp;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Once that is working then slowly add in the macro code as needed&lt;/P&gt;</description>
      <pubDate>Tue, 23 Nov 2021 11:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Upload-file-with-sas-job-execution-and-save-file-on-server/m-p/781907#M249219</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-11-23T11:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file with sas job execution and save file on server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Upload-file-with-sas-job-execution-and-save-file-on-server/m-p/782002#M249263</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;Upload a xlsx File&amp;lt;/title&amp;gt;
&amp;lt;style type="text/css"&amp;gt;

.pointer {
  cursor: pointer;
}

[Other Cascading Style Sheet code here]

&amp;lt;/style&amp;gt;

&amp;lt;/head&amp;gt;

&amp;lt;body role="main"&amp;gt;


&amp;lt;h2&amp;gt;&amp;lt;font face='Univers Black'&amp;gt;Policy 1104&amp;lt;/h2&amp;gt;
&amp;lt;h2&amp;gt;Upload a xlsx File&amp;lt;/h2&amp;gt;

&amp;lt;hr/&amp;gt;

&amp;lt;form action="/SASJobExecution/" method="post" target="_SASResults"
  enctype="multipart/form-data"&amp;gt;

&amp;lt;input type="hidden" name="_program" value="/SOPRA/form_upload"&amp;gt;
&amp;lt;input type="hidden" name="_action" value="execute"/&amp;gt;
&amp;lt;input type="hidden" name="_output_type" value="ods_html5"/&amp;gt;
&amp;lt;input type="hidden" name="_csrf" value="$CSRF$"&amp;gt;


&amp;lt;br/&amp;gt;

&amp;lt;label for=" myfile"&amp;gt;Choose a xlsx file to upload:&amp;lt;/label&amp;gt;
&amp;lt;input type="file" name="myfile" id=" myfile" required class="pointer"/&amp;gt;

&amp;lt;br/&amp;gt;
&amp;lt;br/&amp;gt;

&amp;lt;hr/&amp;gt;

&amp;lt;input type="submit" value="Upload" class="pointer"/&amp;gt;

&amp;lt;/form&amp;gt;

&amp;lt;!--chiamata al job execution per calcolo kpi--&amp;gt;



&amp;lt;form action="/SASJobExecution/" method="post" target="_SASResults"
  enctype="multipart/form-data"&amp;gt;

&amp;lt;input type="hidden" name="_program" value="/SOPRA/calcolo_kpi"&amp;gt;
&amp;lt;input type="hidden" name="_action" value="execute"/&amp;gt;
&amp;lt;input type="hidden" name="_output_type" value="ods_html5"/&amp;gt;
&amp;lt;input type="hidden" name="_csrf" value="$CSRF$"&amp;gt;
&amp;lt;input type="submit" name="send" id="send" value="Calculate KPI" class="pointer"/&amp;gt;
&amp;lt;!--&amp;lt;label for="_debug"&amp;gt;Show SAS Log&amp;lt;/label&amp;gt;--&amp;gt;


&amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any validmemname=extend;

%macro read_uploaded_files;


    %put Total files: &amp;amp;_WEBIN_FILE_COUNT;


    
  
 filename upload filesrvc parenturi="&amp;amp;SYS_JES_JOB_URI"  
 name="&amp;amp;_WEBIN_FILENAME" 
 contenttype="&amp;amp;_WEBIN_CONTENT_TYPE";	
  
  
 %put valore WEBIN_FILENAME -----&amp;gt; &amp;amp;_WEBIN_FILENAME.;
 %put valore SYS_JES_JOB_URI -----&amp;gt;&amp;amp;SYS_JES_JOB_URI.;

  %put valore contenttype ------&amp;gt;&amp;amp;_WEBIN_CONTENT_TYPE.;


 *Set options to support non-SAS name;

options validvarname=any validmemname=extend;

%put nome file ------&amp;gt;&amp;amp;_WEBIN_FILENAME.;



filename outfile "/sasgrid/hseq/1_0/iup_1104/file/prova.xlsx";



data _null_;
   length msg $ 384;
   rc=fcopy('upload', 'outfile');
   if rc=0 then
      put 'Copied upload to outfile';
   else do;
      msg=sysmsg();
      put rc= msg=;
   end;
run;




proc import datafile=upload
  out=work.mydata
  dbms=xlsx
  replace;
   sheet='IBE_02';
run; 
quit;

proc print data=mydata;
run;



/*
ods excel file="/sasgrid/hseq/1_0/iup_1104/file/&amp;amp;_WEBIN_FILENAME.";
ods excel close;
*/

%put verifica ----&amp;gt;&amp;amp;syscc.;

%if (&amp;amp;syscc.&amp;lt;=4 or &amp;amp;syscc.=3000) %then %do;

data a;
valore='Insert Completed';
run;
proc print data=a noobs style= dataemphasis label;
var valore;
label valore='Result';
run;

%end;

%else %do;

data a;
valore='Insert Error';
run;
proc print data=a noobs style= dataemphasis label;
var valore;
label valore='Try again';
run;


%end;





%mend;
%read_uploaded_files;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE id="tw-target-text" class="tw-data-text tw-text-large tw-ta" dir="ltr" data-placeholder="Traduzione"&gt;&lt;SPAN class="Y2IQFc"&gt;the user inserts the excel file through an html form.
the file is saved on a physical path of the server in order to be processed, but when it is read it is "corrupt".
Any suggestions?&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Nov 2021 16:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Upload-file-with-sas-job-execution-and-save-file-on-server/m-p/782002#M249263</guid>
      <dc:creator>dipand</dc:creator>
      <dc:date>2021-11-23T16:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file with sas job execution and save file on server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Upload-file-with-sas-job-execution-and-save-file-on-server/m-p/782899#M249588</link>
      <description>&lt;P&gt;My team have built two free / semi-free tools that can help you with this particular task:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;1) File uploader.&amp;nbsp; A SASjs web app that lets you upload any file to any location on a Viya server -&amp;nbsp;&lt;A href="https://github.com/sasjs/fileuploader" target="_blank"&gt;https://github.com/sasjs/fileuploader&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Data Controller.&amp;nbsp; Free for 5 users, you can drag &amp;amp; drop excel files directly into any (matching) SAS table.&amp;nbsp; &lt;A href="https://datacontroller.io" target="_blank"&gt;https://datacontroller.io&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Nov 2021 12:38:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Upload-file-with-sas-job-execution-and-save-file-on-server/m-p/782899#M249588</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-11-29T12:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Upload file with sas job execution and save file on server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Upload-file-with-sas-job-execution-and-save-file-on-server/m-p/783117#M249671</link>
      <description>thanks for your help.</description>
      <pubDate>Tue, 30 Nov 2021 12:49:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Upload-file-with-sas-job-execution-and-save-file-on-server/m-p/783117#M249671</guid>
      <dc:creator>dipand</dc:creator>
      <dc:date>2021-11-30T12:49:07Z</dc:date>
    </item>
  </channel>
</rss>

