<?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: Separating .tar in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Separating-tar-files-in-SAS/m-p/621083#M182538</link>
    <description>&lt;P&gt;The proper method to deal with a .tar.gz file is this:&lt;/P&gt;
&lt;PRE&gt;gzip -dc file.tar.gz|tar -xf -&lt;/PRE&gt;
&lt;P&gt;The first part decompresses the file to the initial tar stream and sends it to stdout, the second extracts all files from the stdin stream and writes them to the current working directory. By using other tar options, you can extract the names of the files in the tar, or extract specific files from the stream.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"tar" is short for "tape archive", this utility was basically designed for sequential tape storage.&lt;/P&gt;</description>
    <pubDate>Thu, 30 Jan 2020 08:55:19 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-01-30T08:55:19Z</dc:date>
    <item>
      <title>Separating .tar files in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-tar-files-in-SAS/m-p/620960#M182500</link>
      <description>&lt;P&gt;I have a .tar.gz to be separated. The following code downloads the file and removes the .gz part.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename dmrs "%sysfunc(getoption(work))\dmrs.tar.gz";

proc http url="http://www.kentdaniel.net/data/dmrs/dmrs.tar.gz" out=dmrs;
run;

filename dmrs zip "%sysfunc(getoption(work))\dmrs.tar.gz" gzip;
filename dmrs0 "%sysfunc(getoption(work))\dmrs.tar";

data _null_;
	infile dmrs recfm=n;
	file dmrs0 recfm=n;
	input;
	put _infile_;
run;

filename dmrs0 zip "%sysfunc(getoption(work))\dmrs.tar";
%let i=%sysfunc(dopen(dmrs0));
%put %sysfunc(dnum(&amp;amp;i.));
%let j=%sysfunc(dclose(&amp;amp;i.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code successfully unzips the .tar.gz but is unsuccessful in separating each member inside the .tar. Can ZIP in FILENAME read a .tar as well? I am reading &lt;A href="https://blogs.sas.com/content/sasdummy/2017/10/10/reading-writing-gzip-files-sas/" target="_blank" rel="noopener"&gt;this .gz-related blog post&lt;/A&gt;, but a bit unsure. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 12:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-tar-files-in-SAS/m-p/620960#M182500</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-01-30T12:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Separating .tar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-tar-files-in-SAS/m-p/620970#M182501</link>
      <description>&lt;P&gt;A&lt;STRONG&gt; tar&lt;/STRONG&gt; file is a bundling of files, but not compressed.&amp;nbsp; The gzip action compresses this single bundle.&amp;nbsp; So in concept,&amp;nbsp;&lt;STRONG&gt;tar&lt;/STRONG&gt; plus&amp;nbsp;&lt;STRONG&gt;gzip&lt;/STRONG&gt; is like creating a zip file, which is an archive of compressed files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But&amp;nbsp;&lt;STRONG&gt;zip&lt;/STRONG&gt; is not the same as&amp;nbsp;&lt;STRONG&gt;tar&lt;/STRONG&gt; or&amp;nbsp;&lt;STRONG&gt;tar.gz&lt;/STRONG&gt;, so the FILENAME ZIP method can't uncompress these.&amp;nbsp; I think you'll have to use the operating system&amp;nbsp;&lt;STRONG&gt;tar -xf&lt;/STRONG&gt; command to do that.&amp;nbsp; I'm not aware of any SAS function or method to perform that step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good tip from&amp;nbsp;&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;BLOCKQUOTE&gt;
&lt;P&gt;The proper method to deal with a .tar.gz file is this:&lt;/P&gt;
&lt;PRE&gt;gzip -dc file.tar.gz|tar -xf -&lt;/PRE&gt;
&lt;P&gt;The first part decompresses the file to the initial tar stream and sends it to stdout, the second extracts all files from the stdin stream and writes them to the current working directory. By using other tar options, you can extract the names of the files in the tar, or extract specific files from the stream.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"tar" is short for "tape archive", this utility was basically designed for sequential tape storage.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 30 Jan 2020 12:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-tar-files-in-SAS/m-p/620970#M182501</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2020-01-30T12:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Separating .tar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-tar-files-in-SAS/m-p/620977#M182504</link>
      <description>&lt;P&gt;This code (1) downloads the dmrs.tar.gz file (which contains just a dmrs.tar file), (2) removes the .gz part inflating the downloaded file. It seems SAS does not support the last piece of the puzzle—unbinding the members inside the .tar—yet. Thank you for this quick response.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2020 20:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-tar-files-in-SAS/m-p/620977#M182504</guid>
      <dc:creator>Junyong</dc:creator>
      <dc:date>2020-01-29T20:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Separating .tar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-tar-files-in-SAS/m-p/621083#M182538</link>
      <description>&lt;P&gt;The proper method to deal with a .tar.gz file is this:&lt;/P&gt;
&lt;PRE&gt;gzip -dc file.tar.gz|tar -xf -&lt;/PRE&gt;
&lt;P&gt;The first part decompresses the file to the initial tar stream and sends it to stdout, the second extracts all files from the stdin stream and writes them to the current working directory. By using other tar options, you can extract the names of the files in the tar, or extract specific files from the stream.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"tar" is short for "tape archive", this utility was basically designed for sequential tape storage.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 08:55:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-tar-files-in-SAS/m-p/621083#M182538</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-01-30T08:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: Separating .tar</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Separating-tar-files-in-SAS/m-p/691353#M210406</link>
      <description>&lt;P&gt;I realize this thread is a bit old but I just noticed it and wanted to weigh in with two points.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A compressed tar file (typically with ".tar.gz" or ".tgz" extension) is the result of two operations - creating a single-file archive from a group of files (the "tar" part) and compressing that archive (the "gzip" part). The tar utility provided in most variants of *nix include the ability to compress/decompress as part of the process. This can be accomplished on the creation of a tar file by including the "z" switch, e.g., tar -cvzf &amp;lt;tar-filename&amp;gt; &amp;lt;files-to-include&amp;gt;. The same "z" switch will work when extracting one or more files. This means that there is no need to uncompress the file before using the tar command - you can combine those steps and gain the benefit of smaller disk use for the compressed tar file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly, using PIPE on a FILENAME statement,&amp;nbsp; you can read an individual CSV or other file from a compressed tar file without ever having to extract anything to disk as an intermediate. Here's an example that would allow one to read a single CSV file from a tarball into a SAS dataset using the "O" switch (that's a capital letter "O") to write the extract results to STDOUT (aka, "the console" instead of a file):&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;FILENAME mycsv PIPE "tar -xzOf /mypath/mytarball.tar.gz ./one.csv";&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;DATA WORK.ONE;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; INFILE mycsv DELIMITER=',' MISSOVER DSD FIRSTOBS=2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; INPUT...&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Oct 2020 17:46:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Separating-tar-files-in-SAS/m-p/691353#M210406</guid>
      <dc:creator>srobc</dc:creator>
      <dc:date>2020-10-13T17:46:57Z</dc:date>
    </item>
  </channel>
</rss>

