<?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: import multiple files in multiple folders with the same data structure into one file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252202#M47805</link>
    <description>&lt;P&gt;I read that post recently. Actually I used it successully when reading files in the same folder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now my task is more difficult, because I need to loop the folders as well.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Feb 2016 20:37:15 GMT</pubDate>
    <dc:creator>fengyuwuzu</dc:creator>
    <dc:date>2016-02-24T20:37:15Z</dc:date>
    <item>
      <title>import multiple files in multiple folders with the same data structure into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252198#M47802</link>
      <description>&lt;P&gt;I have 637 folders, which contain 12,256 csv files. each folder may have different mumber of csv files.&lt;/P&gt;
&lt;P&gt;each file is for one person. They all have the same header columns in all csv files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can important one file correctly. so based on that, I may be able to import and append all of them into one sungle file.&lt;/P&gt;
&lt;P&gt;Can anyone kindly give me a template how to set up the loops to loop through all the folders and all the files in each folder?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 20:25:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252198#M47802</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-02-24T20:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: import multiple files in multiple folders with the same data structure into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252201#M47804</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 20:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252201#M47804</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-24T20:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: import multiple files in multiple folders with the same data structure into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252202#M47805</link>
      <description>&lt;P&gt;I read that post recently. Actually I used it successully when reading files in the same folder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now my task is more difficult, because I need to loop the folders as well.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 20:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252202#M47805</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-02-24T20:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: import multiple files in multiple folders with the same data structure into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252203#M47806</link>
      <description>&lt;P&gt;You'll need some modifications to the macro I linked to.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Get a list of files into a dataset, use the OS to list files. &amp;nbsp;There's quite a few samples on here so a short search should pop up something.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Create a reference to a file - dummy file not used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;file my_file 'myfile.txt';
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;3. SET the data set from #1 into the data set&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. Modify the infile statement to use the variable from #1 that contains the file path using the filevar option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile my_file eov=eov filevar=myfile filename=filename truncover;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Feb 2016 20:39:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252203#M47806</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-24T20:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: import multiple files in multiple folders with the same data structure into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252230#M47827</link>
      <description>&lt;P&gt;I updated the answer to account for this. If you have issues, post your full code and error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 21:19:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252230#M47827</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-02-24T21:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: import multiple files in multiple folders with the same data structure into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252232#M47829</link>
      <description>I willl give it a try and see how it goes. &lt;BR /&gt;&lt;BR /&gt;Thank you very much!!</description>
      <pubDate>Wed, 24 Feb 2016 21:21:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252232#M47829</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-02-24T21:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: import multiple files in multiple folders with the same data structure into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252236#M47832</link>
      <description>&lt;P&gt;How about a combination of FILEVAR and wildcard? &amp;nbsp;These folder names are UNIX. &amp;nbsp;I forget your OS. &amp;nbsp;You can use programming (not shown) to create your 600 or so folder paths.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data folders;
   input folder $80.;
   cards;
~/folder01
~/folder02
;;;;
   run;
data _null_;
   set folders;
   length filename filevar $128;
   filevar=catx('/',folder,'*.csv');
   put filevar=;
   infile dummy filevar=filevar filename=filename eov=eov end=eof;
   do _n_ = 1 by 1 while(not eof);
      input @;
      if _n_ eq 1 or eof then do;
         put 'NOTE: ' filename= eov=;
         end;
      input;
      end;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 21:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252236#M47832</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2016-02-24T21:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: import multiple files in multiple folders with the same data structure into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252299#M47855</link>
      <description>&lt;P&gt;I found a good macro to loop all folders &lt;A href="http://support.sas.com/kb/45/805.html" target="_self"&gt;http://support.sas.com/kb/45/805.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2016 06:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/import-multiple-files-in-multiple-folders-with-the-same-data/m-p/252299#M47855</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2016-02-25T06:03:54Z</dc:date>
    </item>
  </channel>
</rss>

