<?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: unzip sas problems:    input  and unzip files by batch in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/670190#M201145</link>
    <description>&lt;P&gt;Thank you very much Tom.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested run your (step by step) code below as well. I found that&amp;nbsp; the step-by-step codes give me file name as full name with 'path'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, in this solution code, the first step data all the filenames,&amp;nbsp; but the data removed all the path to these file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;so in second step,&amp;nbsp; I added the path&amp;nbsp; as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;fname= '&amp;amp;path\'||filename.&amp;nbsp; &amp;nbsp;Everything works perfectly.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jul 2020 18:41:20 GMT</pubDate>
    <dc:creator>pensarchem</dc:creator>
    <dc:date>2020-07-17T18:41:20Z</dc:date>
    <item>
      <title>unzip sas problems:    input  and unzip files by batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669593#M200892</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I got hundreds of file need to unzip. There are two major problems;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1, input:&amp;nbsp; &amp;nbsp;right now, 'input;' does not work, only work when you specify the variables and length and format, this causes lots of trouble, as we have to re-define all the variables and format. Especially when dealing with different table, it's a disaster.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I hope to have a simple command to universally treat input;&lt;/P&gt;&lt;P&gt;2, Any way to unzip a batch of files?&amp;nbsp; Got hundreds, batch by batch and I don't want to do it one by one.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 17:07:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669593#M200892</guid>
      <dc:creator>pensarchem</dc:creator>
      <dc:date>2020-07-15T17:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: unzip sas problems:    input  and unzip files by batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669603#M200898</link>
      <description>#1 is not really solvable. You can use PROC IMPORT but I'd highly advise against it as its a guessing procedure and I guarantee it's going to make a mistake guessing your types. If that's fine with you you can use PROC IMPORT.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#2 Have you considered reading the files straight from the ZIP file? &lt;BR /&gt;That process is illustrated here &lt;A href="https://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-sas/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2015/05/11/using-filename-zip-to-unzip-and-read-data-files-in-sas/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Then you can turn that into a macro to process all your ZIP files.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Jul 2020 17:21:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669603#M200898</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-15T17:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: unzip sas problems:    input  and unzip files by batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669610#M200903</link>
      <description>&lt;PRE class="sas"&gt;&lt;SPAN&gt;filename&lt;/SPAN&gt; fromzip ZIP &lt;SPAN&gt;"C:\Logs\SEGuide_log.10168.txt.gz"&lt;/SPAN&gt; GZIP;
&lt;SPAN&gt;data&lt;/SPAN&gt; logdata;   
   &lt;SPAN&gt;infile&lt;/SPAN&gt; fromzip; &lt;SPAN&gt;/* read directly from compressed file */&lt;/SPAN&gt;
   &lt;SPAN&gt;input&lt;/SPAN&gt;  &lt;SPAN&gt;date&lt;/SPAN&gt; : yymmdd10. &lt;SPAN&gt;time&lt;/SPAN&gt; : anydttme. ;
   &lt;SPAN&gt;format&lt;/SPAN&gt; &lt;SPAN&gt;date&lt;/SPAN&gt; date9. &lt;SPAN&gt;time&lt;/SPAN&gt; timeampm.;
&lt;SPAN&gt;run;&lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Hi Reeza, thanks for you advice.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1,&amp;nbsp; the above code is is similar to what I used.&amp;nbsp; I will try proc import.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2, I thought about it, if there is no better choice, macro is the only way I guess.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 17:31:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669610#M200903</guid>
      <dc:creator>pensarchem</dc:creator>
      <dc:date>2020-07-15T17:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: unzip sas problems:    input  and unzip files by batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669679#M200917</link>
      <description>&lt;P&gt;So you don't have ZIP files at all? Just GZIP files?&amp;nbsp; If so that makes it much easier to read all of the files in one data step.&amp;nbsp; First get a list of the files into a dataset.&amp;nbsp; For example by reading the output of dir command (or ls or find on unix) command.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data files;
  infile 'dir C:\Logs\SEGuide_log.*.txt.gz&amp;nbsp;/b'&amp;nbsp;pipe truncover;
&amp;nbsp;&amp;nbsp;input&amp;nbsp;filename&amp;nbsp;$256.&amp;nbsp;;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now use that list to drive the data step that reads the files.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data logdata;   
   set files;
   fname=filename ;
   infile logfile zip gzip filevar=fname end=eof;
   do while (not eof);
     input  date : yymmdd10. timestamp : anydttme. ;
     output;
   end;
   format date date9. timestamp timeampm.;
run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Jul 2020 19:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669679#M200917</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-15T19:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: unzip sas problems:    input  and unzip files by batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669709#M200927</link>
      <description>&lt;P&gt;Thanks for your advice Tom.&amp;nbsp; &amp;nbsp;yeah, not zip file, but .gz file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;First step indeed generate a list of files I want.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is second step.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1,&amp;nbsp; &amp;nbsp;All the data store in 'DATA' folder, which I only have access to read, not write;&lt;/P&gt;&lt;P&gt;2,&amp;nbsp; No matter I create a folder and use libname ,&amp;nbsp; or just under sas work file.&amp;nbsp; &amp;nbsp;The error message is always:&lt;/P&gt;&lt;P&gt;ERROR: Open failure for C:\WINDOWS\SYSTEM32\filename&amp;nbsp; during attempt to create a local file handle.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so I am not sure if this is a path problem (which does not link to orginial 'DATA' folder) or it's a unzip problem.&amp;nbsp; thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 20:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669709#M200927</guid>
      <dc:creator>pensarchem</dc:creator>
      <dc:date>2020-07-15T20:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: unzip sas problems:    input  and unzip files by batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669716#M200930</link>
      <description>&lt;P&gt;Please show the actual code run. And SAS log if possible.&lt;/P&gt;
&lt;P&gt;The only reason that data step would even attempt to write somewhere would be if you messed up the DATA statement.&amp;nbsp; Just use the exact code I used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and it will create a dataset named WORK.WANT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 20:54:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669716#M200930</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-15T20:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: unzip sas problems:    input  and unzip files by batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669718#M200931</link>
      <description>&lt;P&gt;Sorry, it's under Safe Environment, so I could not copy anything out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regardless&amp;nbsp; data want; or data&amp;nbsp; &amp;nbsp;libname.want;&lt;/P&gt;&lt;P&gt;the error message is the same as I wrote in last reply.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 20:58:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669718#M200931</guid>
      <dc:creator>pensarchem</dc:creator>
      <dc:date>2020-07-15T20:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: unzip sas problems:    input  and unzip files by batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669722#M200934</link>
      <description>You don't need to copy anything out, you can copy to work library temporarily to unzip/zip.</description>
      <pubDate>Wed, 15 Jul 2020 21:03:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669722#M200934</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-15T21:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: unzip sas problems:    input  and unzip files by batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669754#M200946</link>
      <description>&lt;P&gt;So do it step by step.&lt;/P&gt;
&lt;P&gt;1) Make sure you can create a dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
  x=1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2) Make sure you can read one of the gzip files.&amp;nbsp; Like your original example.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test2;
  infile '.....txt.gz' zip gzip ;
  input ....;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;3) Now try to read it using FILEVAR= option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test3;
  fname='.....txt.gz';
  infile dummy zip gzip filevar=fname;
  input ....;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;4) Make a dataset with one filename and try reading it using that.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test4;
  filename='.....txt.gz';
run;
data test5;
  set test4;
  fname=filename;
  infile dummy zip gzip filevar=fname end=eof;
  do while (not eof);
    input ....;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now replace TEST4 dataset with a larger list of filenames and then re-run the step to use it to create TEST5.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 00:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/669754#M200946</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-16T00:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: unzip sas problems:    input  and unzip files by batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/670190#M201145</link>
      <description>&lt;P&gt;Thank you very much Tom.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested run your (step by step) code below as well. I found that&amp;nbsp; the step-by-step codes give me file name as full name with 'path'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, in this solution code, the first step data all the filenames,&amp;nbsp; but the data removed all the path to these file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;so in second step,&amp;nbsp; I added the path&amp;nbsp; as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;fname= '&amp;amp;path\'||filename.&amp;nbsp; &amp;nbsp;Everything works perfectly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 18:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/670190#M201145</guid>
      <dc:creator>pensarchem</dc:creator>
      <dc:date>2020-07-17T18:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: unzip sas problems:    input  and unzip files by batch</title>
      <link>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/670192#M201146</link>
      <description>&lt;P&gt;One of the "features" of the Window/DOS command.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 18:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/unzip-sas-problems-input-and-unzip-files-by-batch/m-p/670192#M201146</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-07-17T18:51:29Z</dc:date>
    </item>
  </channel>
</rss>

