<?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: Read some zipped files from some folders in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Read-some-zipped-files-from-some-folders/m-p/626882#M20451</link>
    <description>&lt;P&gt;Thanks for this part, yes, it is text files. I see how to read them now, but I am not sure how to iterate over folders I need iterate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Feb 2020 15:19:56 GMT</pubDate>
    <dc:creator>eduard1231</dc:creator>
    <dc:date>2020-02-24T15:19:56Z</dc:date>
    <item>
      <title>Read some zipped files from some folders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Read-some-zipped-files-from-some-folders/m-p/626782#M20432</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess I have 3 issues. I need to read files, that have filepath in following format:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;x1/x2/x3/x4/file&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, I want to iterate over SOME x1, ALL x2, SOME x3, ALL x4. Finally when I am in x4 folder, I have 2 types of file's name in following format:&lt;/P&gt;&lt;P&gt;file_name_date&lt;/P&gt;&lt;P&gt;file_name_date.new&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, from those I want to read only file_name_date files, and I want to skip all&amp;nbsp;file_name_date.new.&lt;/P&gt;&lt;P&gt;file_name part of file is constant the only thing changes in file_name_date is the date part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, this file is zipped. Can sas read zipped file?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally, when I read this file and did some manipulation with it, I want to save it and then start to work with new file. When I iterate over all files in folder, i will go back from x4 level to x3 level, change folder, go to new x4 level and repeat process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, I guess it is confusing. You are more than welcome to ask extra questions, I will try to explain as hard as I can&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ed&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 02:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Read-some-zipped-files-from-some-folders/m-p/626782#M20432</guid>
      <dc:creator>eduard1231</dc:creator>
      <dc:date>2020-02-24T02:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: Read some zipped files from some folders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Read-some-zipped-files-from-some-folders/m-p/626786#M20435</link>
      <description>Are the files zipped text files or sas7bdat files? If this is text files everything you want is possible. If it's sas formatted files then I don't think it's as easy. &lt;BR /&gt;&lt;BR /&gt;There's a FILENAME ZIP option that supports reading from zipped files. If you google the term, Chris Hemidinger has written some good blog posts on reading from zipped files, have you explored those posts already?</description>
      <pubDate>Mon, 24 Feb 2020 02:45:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Read-some-zipped-files-from-some-folders/m-p/626786#M20435</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-02-24T02:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Read some zipped files from some folders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Read-some-zipped-files-from-some-folders/m-p/626882#M20451</link>
      <description>&lt;P&gt;Thanks for this part, yes, it is text files. I see how to read them now, but I am not sure how to iterate over folders I need iterate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Feb 2020 15:19:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Read-some-zipped-files-from-some-folders/m-p/626882#M20451</guid>
      <dc:creator>eduard1231</dc:creator>
      <dc:date>2020-02-24T15:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Read some zipped files from some folders</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Read-some-zipped-files-from-some-folders/m-p/626895#M20452</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/286929"&gt;@eduard1231&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for this part, yes, it is text files. I see how to read them now, but I am not sure how to iterate over folders I need iterate&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I usually find it easiest to generate the full list of files into a dataset.&amp;nbsp; Usually by reading output of appropriate operating system command (dir, ls , find etc.).&amp;nbsp; &amp;nbsp;There are many examples on this site for how to do that.&amp;nbsp; For example on Unix you might want to use the FIND command:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data filelist;
  infile "find /x1/" pipe truncover ;
  input filename $256. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then I can apply selection/exclusion logic to the file names either in that step or another step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where scan(filename,3,'/') in ('log','saslog') ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you have the list of file just use it to call the code to process one file.&amp;nbsp;&amp;nbsp;So if you had a macro that processed one file. Call it %ONEFILE() you can just use a data step to generate one call for each observation in the dataset with the names of the files to process.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set filelist ;
  call execute(cats('%nrstr(%onefile)(',filename,')'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Feb 2020 16:27:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Read-some-zipped-files-from-some-folders/m-p/626895#M20452</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-02-24T16:27:40Z</dc:date>
    </item>
  </channel>
</rss>

