<?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: Zipping xlsx files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/705021#M280510</link>
    <description>&lt;P&gt;As already mentioned, zipping xlsx files makes no sense in terms of disk space reduction, as xlsx files are already zipped archives of xml data.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;has given a nice example for using SAS to add files to a zip archive.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 10 Dec 2020 11:01:13 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-12-10T11:01:13Z</dc:date>
    <item>
      <title>Zipping xlsx files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/419652#M280504</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to zip .xlsx files with SAS code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;F15&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 18:05:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/419652#M280504</guid>
      <dc:creator>May15</dc:creator>
      <dc:date>2017-12-08T18:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Zipping xlsx files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/419654#M280505</link>
      <description>&lt;P&gt;That's useless. xlsx files are already zipped.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 18:07:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/419654#M280505</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-08T18:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Zipping xlsx files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/419655#M280506</link>
      <description>&lt;P&gt;I use 7ZIP sometimes and this approach, using X commands.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options noxwait noxsync;

data _null_;
 *Path to winzip program;
  zipexe='"C:\Program Files\7-Zip\7z.exe" a -tzip';
 *Zip file name;
  zipfile="C:\My Documents\Sample.zip";
 *File to be zipped;
  file="C:\Temp\Sample.txt";
 *Full cmd line to be passed to command line. It embeds the quotes for paths with spaces;
  cmd = zipexe ||' "'|| zipfile ||'" "'|| file ||'"' ; 
 *Place note in log;
  putlog "NOTE-Processing command" cmd;
 *Execute command;
  call system(cmd);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/9602105" target="_blank"&gt;https://gist.github.com/statgeek/9602105&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or there's ODS PACKAGE as well:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2014/01/28/create-zip-ods-package/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2014/01/28/create-zip-ods-package/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And FileName ZIP approach, similar to above:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2016/03/04/add-files-to-a-zip-archive-with-filename-zip/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2016/03/04/add-files-to-a-zip-archive-with-filename-zip/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 18:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/419655#M280506</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-08T18:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Zipping xlsx files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/419687#M280507</link>
      <description>&lt;P&gt;Why?&amp;nbsp; XLSX files are already zipped, so it will not save space.&amp;nbsp; Is it just to package multiple files together?&lt;/P&gt;
&lt;P&gt;If you can use PIPE then use that to run system commands to build the ZIP file from the individual files.&lt;/P&gt;
&lt;P&gt;But if that is disabled then you can use the ZIP engine and FCOPY() function to move XLSX files into a ZIP file.&lt;/P&gt;
&lt;P&gt;Here is an example to export SASHELP.CLASS and SASHELP.CARS as XLSX and TXT files into a single ZIP file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Note that PROC EXPORT to not smart enough to write directly to members in a zip file, so instead i had it write to separate physical files.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dir=%sysfunc(pathname(work));

filename xlsx1 "&amp;amp;dir/class.xlsx" recfm=n;
proc export data=sashelp.class outfile=xlsx1 dbms=xlsx replace;
run;
filename xlsx2 "&amp;amp;dir/cars.xlsx" recfm=n;
proc export data=sashelp.cars outfile=xlsx2 dbms=xlsx replace ;
run;

filename target1 zip "&amp;amp;dir/sample.zip" member='class.xlsx' recfm=n ;
filename target2 zip "&amp;amp;dir/sample.zip" member='cars.xlsx' recfm=n ;
data _null_;
  rc=fcopy('xlsx1','target1');
  put rc= ;
  rc=fcopy('xlsx2','target2');
  put rc= ;
run;

filename target zip "&amp;amp;dir/sample.zip" ;
data _null_;
  set sashelp.class ;
  file target('class.txt') dsd dlm='|' ;
  put (_all_) (+0) ;
run;

data _null_;
  set sashelp.cars ;
  file target('cars.txt') dsd dlm='|' ;
  put (_all_) (+0) ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;So after running that I used the UNZIP command to check what I had created in the ZIP file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  infile "cd &amp;amp;dir ; unzip -Z sample.zip" pipe ;
  input;
  put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Archive:  sample.zip
Zip file size: 53487 bytes, number of entries: 4
-rwx------  2.0 unx     6468 b- defN 17-Dec-08 14:56 class.xlsx
-rwx------  2.0 unx    37711 b- defN 17-Dec-08 14:56 cars.xlsx
-rwx------  2.0 unx      384 t- defN 17-Dec-08 14:56 class.txt
-rwx------  2.0 unx    35877 t- defN 17-Dec-08 14:56 cars.txt
4 files, 80440 bytes uncompressed, 53009 bytes compressed:  34.1%&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2017 20:02:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/419687#M280507</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-12-08T20:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Zipping xlsx files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/419918#M280508</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your suggestions. I'll try to work on a solution based on your ideas. If something comes up, I'll write again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;F15&lt;/P&gt;</description>
      <pubDate>Sun, 10 Dec 2017 13:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/419918#M280508</guid>
      <dc:creator>May15</dc:creator>
      <dc:date>2017-12-10T13:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Zipping xlsx files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/705011#M280509</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I have 20 xlsx files, every time i am zipping as seperate files (getting 20 zipped files,so zipping 20 times). if anyone knows best working solution,please let me know.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 10:17:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/705011#M280509</guid>
      <dc:creator>rajeshm</dc:creator>
      <dc:date>2020-12-10T10:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Zipping xlsx files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/705021#M280510</link>
      <description>&lt;P&gt;As already mentioned, zipping xlsx files makes no sense in terms of disk space reduction, as xlsx files are already zipped archives of xml data.&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;has given a nice example for using SAS to add files to a zip archive.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Dec 2020 11:01:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Zipping-xlsx-files/m-p/705021#M280510</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-12-10T11:01:13Z</dc:date>
    </item>
  </channel>
</rss>

