<?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: Unzipping zip and gz files using SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/495187#M130645</link>
    <description>&lt;P&gt;Then your option is to a) use x commands to shell the commands out to the operating system as I present above, or do it outside of SAS.&amp;nbsp; No reason why you cannot do it via normal batch file:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/17077964/windows-batch-script-to-unzip-files-in-a-directory" target="_blank"&gt;https://stackoverflow.com/questions/17077964/windows-batch-script-to-unzip-files-in-a-directory&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not all processing needs to be done in SAS.&lt;/P&gt;</description>
    <pubDate>Thu, 13 Sep 2018 08:04:45 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-09-13T08:04:45Z</dc:date>
    <item>
      <title>Unzipping zip and gz files using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/494730#M130435</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;I am a newbie to SAS programming and I&amp;nbsp;need a help on unzipping the gz and zip files using SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a .zip file which contains several .csv.gz files within it.&lt;/P&gt;&lt;P&gt;I could find how to unzip .zip files and how to open .gz files, but it seems quite complicated to do both at once.&lt;/P&gt;&lt;P&gt;what I need is to create a new unzipped files of .csv files. (or, just reading as datasets would be helpful too)&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 07:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/494730#M130435</guid>
      <dc:creator>LzEr23</dc:creator>
      <dc:date>2018-09-12T07:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: Unzipping zip and gz files using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/494743#M130441</link>
      <description>&lt;P&gt;Why do you have two levels of compression in the first place? Sounds like a zip from linux has then been moved over to windows, where someone else has then zipped them, bit daft.&lt;/P&gt;
&lt;P&gt;Anyways, most zip programs, winzip, 7zip should be able to deal with both file types.&amp;nbsp; So you would need to:&lt;/P&gt;
&lt;P&gt;1) Get filenames&lt;/P&gt;
&lt;P&gt;2) Unzip each filename using command line extract&lt;/P&gt;
&lt;P&gt;3) Get list of files&lt;/P&gt;
&lt;P&gt;4) Unzip each filename using command line extract&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A shell of a program might look like:&lt;/P&gt;
&lt;PRE&gt;filename tmp pipe 'dir "c:/data/*.zip" /b';

data _null_;
  infile tmp;
  length nm $200;
  input nm $;
  call execute(cat('x "c:/programfiles/7zip/7zip.exe -e "',strip(nm),'";'));
run;

filename tmp pipe 'dir "c:/data/*.gz" /b';

data _null_;
  infile tmp;
  length nm $200;
  input nm $;
  call execute(cat('x "c:/programfiles/7zip/7zip.exe -e "',strip(nm),'";'));
run;
&lt;/PRE&gt;
&lt;P&gt;Question is, is it worth coding this?&amp;nbsp; You can select all files, right click and select extract to /* with 7zip for instance, its not really a huge effort.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 08:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/494743#M130441</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-12T08:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Unzipping zip and gz files using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/494785#M130452</link>
      <description>&lt;P&gt;SAS 9.4 has a native capability to read ZIP files using FILENAME ZIP.&amp;nbsp; And it if you have SAS 9.4 Maint 5, the method also supports GZIP files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because you have a ZIP of GZ files, you're looking at a two step process.&amp;nbsp; First, expand the members of the ZIP file with FILENAME ZIP.&amp;nbsp; I have some &lt;A href="https://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-sas/" target="_self"&gt;examples in this blog post&lt;/A&gt;.&amp;nbsp; Note that the process involves "reading" each ZIP member and writing it as a new file to a temporary space -- effectively copying it out of the ZIP archive.&amp;nbsp; At the end of this step, you would have a collection of *.csv.gz files in your temp space.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would then use FILENAME ZIP GZIP to reference each of those csv.gz files in turn.&amp;nbsp; You don't need to explicitly decompress those -- once you assign that fileref, you should be able to process the file with DATA step.&amp;nbsp; See &lt;A href="https://blogs.sas.com/content/sasdummy/2017/10/10/reading-writing-gzip-files-sas/" target="_self"&gt;this blog post about reading GZIP files&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Sep 2018 12:16:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/494785#M130452</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-09-12T12:16:42Z</dc:date>
    </item>
    <item>
      <title>Re: Unzipping zip and gz files using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/495150#M130631</link>
      <description>thank you so much for the help.&lt;BR /&gt;&lt;BR /&gt;I can see that I need to first go through a unzipping process with filename, and when end up with bunch of csv.gz temp files, then I should move on to deal with gzip files.&lt;BR /&gt;&lt;BR /&gt;But unfortunately, the only available sas that I have is sas 9.4 mount 3. And apparently, gzip option does not seem to work on this version of sas.&lt;BR /&gt;&lt;BR /&gt;It has already been a great help, but can I ask for more advice on csv.gz files when I'm not using sas 9.4 mount 5?</description>
      <pubDate>Thu, 13 Sep 2018 04:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/495150#M130631</guid>
      <dc:creator>LzEr23</dc:creator>
      <dc:date>2018-09-13T04:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Unzipping zip and gz files using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/495165#M130632</link>
      <description>Bad news: if xcmd is disabled in your sas session, you can't unzip gz-files during sas execution. With xcmd enabled you can execute 7z, for example, from your sas session.</description>
      <pubDate>Thu, 13 Sep 2018 05:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/495165#M130632</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2018-09-13T05:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Unzipping zip and gz files using SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/495187#M130645</link>
      <description>&lt;P&gt;Then your option is to a) use x commands to shell the commands out to the operating system as I present above, or do it outside of SAS.&amp;nbsp; No reason why you cannot do it via normal batch file:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/17077964/windows-batch-script-to-unzip-files-in-a-directory" target="_blank"&gt;https://stackoverflow.com/questions/17077964/windows-batch-script-to-unzip-files-in-a-directory&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not all processing needs to be done in SAS.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 08:04:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unzipping-zip-and-gz-files-using-SAS/m-p/495187#M130645</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-09-13T08:04:45Z</dc:date>
    </item>
  </channel>
</rss>

