<?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 compres a generated CSV file? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461803#M284850</link>
    <description>&lt;P&gt;Running on a 9.4 M5 environment?&amp;nbsp; Try GZIP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename _dataout zip "/path/cars.csv.gz" GZIP;

proc export data=sashelp.cars
  outfile=_dataout
  dbms=csv replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 12 May 2018 20:48:16 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2018-05-12T20:48:16Z</dc:date>
    <item>
      <title>How to compress a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461785#M284843</link>
      <description>&lt;P&gt;I'm generating a CSV file from a SAS dataset, and I'd like to compress it to zip before downloading it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=sashelp.cars
  outfile=_dataout
  dbms=csv replace;
run;

%let _DATAOUT_MIME_TYPE=text/csv;
%let _DATAOUT_NAME=cars.csv;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I do that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 12:01:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461785#M284843</guid>
      <dc:creator>the_yeti</dc:creator>
      <dc:date>2018-05-14T12:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461786#M284844</link>
      <description>&lt;P&gt;Define _dataout with filename zip.&lt;/P&gt;</description>
      <pubDate>Sat, 12 May 2018 18:54:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461786#M284844</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-12T18:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461792#M284845</link>
      <description>&lt;P&gt;Thank you Kurt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you point me to an example?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried a few different combinations, but no luck...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=sashelp.cars
  outfile=test.zip zip
  dbms=csv replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=sashelp.cars
  outfile=test zip
  dbms=csv replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=sashelp.cars
  outfile='test.zip' zip
  dbms=csv replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 May 2018 19:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461792#M284845</guid>
      <dc:creator>the_yeti</dc:creator>
      <dc:date>2018-05-12T19:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461793#M284846</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename _dataout zip "/path/name.zip";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=sashelp.cars
  outfile=_dataout
  dbms=csv replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 May 2018 19:48:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461793#M284846</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-12T19:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461796#M284847</link>
      <description>&lt;P&gt;Thank you Kurt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That code seems to generate some sort of compressed file, instead of the plain text CSV, however it doesn't seem to be in the ZIP format... It's some other compression I'm afraid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any hint I can use in the `filename` instruction to tell it o use LZMA, etc?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the beginning of the file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="compressed-file.png" style="width: 447px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/20487i085CA526CEF13CAC/image-size/large?v=v2&amp;amp;px=999" role="button" title="compressed-file.png" alt="compressed-file.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 12 May 2018 19:58:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461796#M284847</guid>
      <dc:creator>the_yeti</dc:creator>
      <dc:date>2018-05-12T19:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461799#M284848</link>
      <description>&lt;P&gt;filename zip is compatible with WinZip, and since 9.4M5 also supports the gzip compression.&lt;/P&gt;</description>
      <pubDate>Sat, 12 May 2018 20:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461799#M284848</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-12T20:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461802#M284849</link>
      <description>&lt;P&gt;Hmm I think something odd is happening. The file cannot be opened by Windows. It shows an empty folder.&lt;/P&gt;</description>
      <pubDate>Sat, 12 May 2018 20:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461802#M284849</guid>
      <dc:creator>the_yeti</dc:creator>
      <dc:date>2018-05-12T20:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461803#M284850</link>
      <description>&lt;P&gt;Running on a 9.4 M5 environment?&amp;nbsp; Try GZIP.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename _dataout zip "/path/cars.csv.gz" GZIP;

proc export data=sashelp.cars
  outfile=_dataout
  dbms=csv replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 May 2018 20:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461803#M284850</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-05-12T20:48:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461891#M284851</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code generates a 11-kB file (CSV is 38kB) that when opened with Winzip&amp;nbsp;on Win7&amp;nbsp;&lt;/P&gt;
&lt;P&gt;yields a warning "Cannot open file xxx.zip. It does not appear to be a valid archive"&lt;/P&gt;
&lt;P&gt;with error message : Error: invalid central directory entry (No. 1) encountered.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My version of Winzip seems to be old though. Version 17.5 (10652) 64-bit.&lt;/P&gt;
&lt;P&gt;It may be the version that came with Win7.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 23:10:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461891#M284851</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-05-13T23:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461946#M284852</link>
      <description>&lt;P&gt;&amp;lt;spock&amp;gt;Fascinating&amp;lt;/spock&amp;gt;. 7-zip can open the file, while Windows Explorer shows it empty. UNIX unzip (AIX) comes back with&lt;/P&gt;
&lt;PRE&gt;Archive:  cars.csv.zip
mapname:  conversion of  failed&lt;/PRE&gt;
&lt;P&gt;unzip -l shows&lt;/P&gt;
&lt;PRE&gt;Archive:  cars.csv.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
    37713  05-14-2018 09:34   
---------                     -------
    37713                     1 file
&lt;/PRE&gt;
&lt;P&gt;so there seems to be an unnamed entry that confuses some zip programs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This research led me to reread the documentation of filename zip (following Maxim 1), and I came up with this solution:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename _dataout zip "$HOME/sascommunity/cars.csv.zip" member="cars.csv";

proc export data=sashelp.cars
  outfile=_dataout
  dbms=csv replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The unzip -l now shows&lt;/P&gt;
&lt;PRE&gt;  Length      Date    Time    Name
---------  ---------- -----   ----
    37713  05-14-2018 09:50   cars.csv
---------                     -------
    37713                     1 file
&lt;/PRE&gt;
&lt;P&gt;and UNIX unzip works. Similarly, Windows Explorer now shows the file, and I guess WinZip will also work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW filename zip with the gzip option, as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;, works perfectly without any additional options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS all my tests run on SAS 9.4M5 and AIX, Windows tests on Windows 7.&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 08:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461946#M284852</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-14T08:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461952#M284853</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; Colour me impressed. Well done! I wonder whether this behaviour is expected. &lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 08:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461952#M284853</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-05-14T08:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461954#M284854</link>
      <description>&lt;P&gt;Still up? How late is it now next to "down under"?&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 08:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461954#M284854</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-14T08:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461997#M284855</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;- expected or not, I think it's good practice (maybe essential) to explicitly name the "member" files for the ZIP method, since there can be multiple files in the archive.&amp;nbsp; For GZIP, that's not necessary (or supported) since it's just a single compressed file, not an archive of several files.&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 12:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/461997#M284855</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-05-14T12:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/462010#M284856</link>
      <description>&lt;P&gt;Just to expand on &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;: gzip does not "need" multiple files in an archive, as that is usually handled on a UNIX by tar:&lt;/P&gt;
&lt;PRE&gt;tar -cf - $HOME/path/* | gzip -c - &amp;gt; $HOME/path.gz&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 May 2018 12:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/462010#M284856</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-14T12:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/462224#M284857</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;Late enough that I was home but not so late that I was asleep. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise: After doing some (belated) reading, it seems a member name is required. Either in the form you mentioned or like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="2"&gt;&lt;CODE class=" language-sas"&gt;filename FOO zip 'U:\directory1\testzip.zip';
data _null_;
  file FOO(shoes);&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There we go. My learning for the day. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;&amp;nbsp;even details how to send a SAS data set in a ZIP file &lt;A href="https://blogs.sas.com/content/sasdummy/2016/03/04/add-files-to-a-zip-archive-with-filename-zip/" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;though the new fcopy() function makes this easier.&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="2"&gt;&lt;CODE class=" language-sas"&gt;filename IN      "&amp;amp;path\test.sas7bdat" recfm=n;
filename OUT zip "&amp;amp;path\test.zip" member='test.sas7bdat' ;
%let rc=%sysfunc(fcopy(IN,OUT)); %put &amp;amp;=rc;
&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 23:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/462224#M284857</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-05-14T23:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/477128#M284858</link>
      <description>&lt;P&gt;Thank you Chris.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think my environment might not support GZIP for some reason... I get the following error message:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;!--   THIS MUST BE THE FIRST TAG IN HEAD ELEMENT   --&gt;&lt;/P&gt;&lt;PRE&gt;ERROR: Error in the FILENAME statement.
ERROR 23-2: Invalid option name GZIP.
ERROR: Insufficient authorization to access /sso/biconfig/940/Lev1/SASApp/_DATAOUT.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm running:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename _dataout zip "/path/that/I/know/I/can/write/to/cars.csv.gz" GZIP;

proc export data=sashelp.cars
  outfile=_dataout
  dbms=csv replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="dijitBorderContainer dijitContainer row-fluid dijitLayoutContainer"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 11 Jul 2018 15:33:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/477128#M284858</guid>
      <dc:creator>the_yeti</dc:creator>
      <dc:date>2018-07-11T15:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to compres a generated CSV file?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/477130#M284859</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; ! Adding the member name does the trick!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jul 2018 15:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compress-a-generated-CSV-file/m-p/477130#M284859</guid>
      <dc:creator>the_yeti</dc:creator>
      <dc:date>2018-07-11T15:34:59Z</dc:date>
    </item>
  </channel>
</rss>

