<?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: Stored Process - output to csv files inside a zip in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-output-to-csv-files-inside-a-zip/m-p/772329#M245221</link>
    <description>&lt;P&gt;Why so complicated? And why styles for a CSV file?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename ZIP zip "&amp;amp;wdir/data.zip" member="f1.csv" ;
ods csv file = ZIP;
PROC PRINT DATA=SASHELP.CARS; run;
ods csv close;

filename ZIP zip "&amp;amp;wdir/data.zip" member="f2.csv" ;
ods csv file = ZIP;
PROC PRINT DATA=SASHELP.CARS; run;
ods csv close;
filename ZIP clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Oct 2021 01:53:13 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-10-06T01:53:13Z</dc:date>
    <item>
      <title>Stored Process - output to csv files inside a zip</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-output-to-csv-files-inside-a-zip/m-p/772188#M245164</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently trying to make a stored process with two csv files for output. I already know that the best way for doing this is to output a zip file with these two csv files (the stored process only outputs one file).&lt;/P&gt;&lt;P&gt;That being said, I have the code below for doing so:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let hoje = %sysfunc(today(),date9.);&lt;BR /&gt;%let _ODSDETS=TAGSETS.EXCELXP;  
%let rc=%sysfunc(stpsrv_header('Content-type','application/vnd.zip')); /*define o tipo de arquivo (zip)*/

%let rc=%sysfunc(stpsrv_header('Content-disposition','attachment; filename=temp.csv'));  
 
%let _ODSSTYLE=PEARL;

ods csv file = 'FILE1_&amp;amp;HOJE..csv' options(autofit_height = 'YES' FROZEN_HEADERS = 'YES');
PROC PRINT DATA=FILE1 noobs LABEL 
style(HEADER)={color=black background=white font_weight=bold font_size=10pt font_face=CALIBRI width=1.8in just=c vjust=c} 
										 style(DATA) = {background=white font_size=10pt font_face=CALIBRI};

format MyVAR $char.;  
RUN;
ods csv close;

ods csv file = 'FILE2_&amp;amp;HOJE..csv' options(autofit_height = 'YES' FROZEN_HEADERS = 'YES');
PROC PRINT DATA=FILE2 noobs LABEL 
style(HEADER)={color=black background=white 
				font_weight=bold font_size=10pt font_face=CALIBRI width=1.8in just=c vjust=c} 
										 style(DATA) = {background=white font_size=10pt font_face=CALIBRI};
RUN;
ods csv close;

/*criando pasta zipada*/
ods package(newzip) open nopf;
ods package(newzip) add file='FILE1_&amp;amp;HOJE..csv' path=_webout;
ods package(newzip) add file='FILE2_&amp;amp;HOJE..csv';
ods package(newzip) publish archive 
  properties(
   archive_name="Myfiles.zip" 
   archive_path=_webout
  );
ods package(newzip) close;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the result is an empty file with unknown content type:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JoaoRFalcao_0-1633445960710.png" style="width: 709px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64370i03C54A34806C0445/image-dimensions/709x39?v=v2" width="709" height="39" role="button" title="JoaoRFalcao_0-1633445960710.png" alt="JoaoRFalcao_0-1633445960710.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how I can fix this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reference:&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Export-zip-files-using-ods/td-p/429058" target="_blank" rel="noopener"&gt;Export zip files using ods&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 15:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-output-to-csv-files-inside-a-zip/m-p/772188#M245164</guid>
      <dc:creator>JoaoRFalcao</dc:creator>
      <dc:date>2021-10-05T15:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - output to csv files inside a zip</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-output-to-csv-files-inside-a-zip/m-p/772329#M245221</link>
      <description>&lt;P&gt;Why so complicated? And why styles for a CSV file?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename ZIP zip "&amp;amp;wdir/data.zip" member="f1.csv" ;
ods csv file = ZIP;
PROC PRINT DATA=SASHELP.CARS; run;
ods csv close;

filename ZIP zip "&amp;amp;wdir/data.zip" member="f2.csv" ;
ods csv file = ZIP;
PROC PRINT DATA=SASHELP.CARS; run;
ods csv close;
filename ZIP clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 01:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-output-to-csv-files-inside-a-zip/m-p/772329#M245221</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-10-06T01:53:13Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - output to csv files inside a zip</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-output-to-csv-files-inside-a-zip/m-p/772381#M245247</link>
      <description>&lt;P&gt;Instead of ODS CSV &amp;amp; PROC PRINT, use a data step, it performs much better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;file = 'FILE1_&amp;amp;HOJE..csv'&lt;/LI-CODE&gt;
&lt;P&gt;won't work, as the macro variable will not be resolved inside single quotes. You will also have issues because this is not an absolute path, and SAS will try to write the file in the current working directory of the pooled stored process, where you should not have write permission anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As mentioned, you should define a single filename zip to the webout destination, and then use that file reference in the data step with additional members, something along&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename outzip zip _webout;

data _null_;
file outzip(member1.csv) dlm="," dsd;
set ....;
if _n_ = 1 then put "header,information,here";
put .....;
run;

data _null_;
file outzip(member2.csv) dlm="," dsd;
set ....;
if _n_ = 1 then put "header,information,here";
put .....;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Oct 2021 09:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-output-to-csv-files-inside-a-zip/m-p/772381#M245247</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-06T09:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - output to csv files inside a zip</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-output-to-csv-files-inside-a-zip/m-p/772439#M245269</link>
      <description>&lt;P&gt;You could probably achieve it in one line, using this macro:&amp;nbsp;&amp;nbsp;&lt;A href="https://core.sasjs.io/mp__zip_8sas.html" target="_blank"&gt;https://core.sasjs.io/mp__zip_8sas.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 14:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-output-to-csv-files-inside-a-zip/m-p/772439#M245269</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2021-10-06T14:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - output to csv files inside a zip</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-output-to-csv-files-inside-a-zip/m-p/772507#M245296</link>
      <description>Thanks! I'll try that!</description>
      <pubDate>Wed, 06 Oct 2021 17:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-output-to-csv-files-inside-a-zip/m-p/772507#M245296</guid>
      <dc:creator>JoaoRFalcao</dc:creator>
      <dc:date>2021-10-06T17:59:21Z</dc:date>
    </item>
  </channel>
</rss>

