<?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 How to Input All Files in a Folder? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Input-All-Files-in-a-Folder/m-p/379514#M276930</link>
    <description>&lt;P&gt;&lt;SPAN&gt;I have a question that I suspect has an answer, but I have seached online&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;for quite a long time and have yet to find one solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose I have a folder called "MySasFolder" and inside MySasFolder I have N number of&amp;nbsp;&amp;nbsp;files: "a.xml", &lt;SPAN&gt;"b&lt;/SPAN&gt;&lt;SPAN&gt;.xml",&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;"c&lt;/SPAN&gt;&lt;SPAN&gt;.xml","d.xml" etc. and so on.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;I have to read this data &amp;nbsp;into a SAS dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way that SAS can loop through all files in a folder and input them into one SAS dataset without me having to tell SAS the names of each file ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;When I input each file into the SAS dataset I also need to keep the name of each file as a variable as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;James&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jul 2017 19:18:17 GMT</pubDate>
    <dc:creator>jjames1</dc:creator>
    <dc:date>2017-07-26T19:18:17Z</dc:date>
    <item>
      <title>How to Input All Files in a Folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Input-All-Files-in-a-Folder/m-p/379514#M276930</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have a question that I suspect has an answer, but I have seached online&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;for quite a long time and have yet to find one solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose I have a folder called "MySasFolder" and inside MySasFolder I have N number of&amp;nbsp;&amp;nbsp;files: "a.xml", &lt;SPAN&gt;"b&lt;/SPAN&gt;&lt;SPAN&gt;.xml",&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;"c&lt;/SPAN&gt;&lt;SPAN&gt;.xml","d.xml" etc. and so on.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;I have to read this data &amp;nbsp;into a SAS dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way that SAS can loop through all files in a folder and input them into one SAS dataset without me having to tell SAS the names of each file ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;When I input each file into the SAS dataset I also need to keep the name of each file as a variable as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;James&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 19:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Input-All-Files-in-a-Folder/m-p/379514#M276930</guid>
      <dc:creator>jjames1</dc:creator>
      <dc:date>2017-07-26T19:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to Input All Files in a Folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Input-All-Files-in-a-Folder/m-p/379523#M276931</link>
      <description>&lt;P&gt;Are all the XMLs formatted the same way? They have the same structure?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have a process built to import one file to start with, thats what you need first. Then you can create a list of files and call the macro using CALL EXECUTE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have an example here, but uses XLSX files:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Import_all_files_one_type" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Import_all_files_one_type&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can replace my PROC IMPORT with your import procedure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 19:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Input-All-Files-in-a-Folder/m-p/379523#M276931</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-26T19:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to Input All Files in a Folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Input-All-Files-in-a-Folder/m-p/379531#M276932</link>
      <description>&lt;P&gt;No the xmls are of different structure.&lt;/P&gt;&lt;P&gt;But my SAS code is able to handle all different types of XMLs that I have.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But all these cases I manually input my xml filename into a macro and then do my process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example if I need to read &lt;STRONG&gt;ABC.xml&amp;nbsp;&lt;/STRONG&gt;I do the following&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let variable= ABC

filename output temp;
libname output xmlv2 "/home/test/&amp;amp;variable..xml" automap=replace xmlmap=output;
proc copy in=output out=work noclone;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In my case I want to read from a folder that has thousands of xml files&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I know that this approach is not ideal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 19:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Input-All-Files-in-a-Folder/m-p/379531#M276932</guid>
      <dc:creator>jjames1</dc:creator>
      <dc:date>2017-07-26T19:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to Input All Files in a Folder?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Input-All-Files-in-a-Folder/m-p/379537#M276933</link>
      <description>&lt;P&gt;The idea is still the same. Wrap your current code into a macro, in my example it's called IMPORT_FILE. The other macro LIST_FILES (first one) creates a list of files. The last data step then uses the file paths to import the files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I updated some comments in the program that may help you work through it on your side.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 20:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Input-All-Files-in-a-Folder/m-p/379537#M276933</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-26T20:01:07Z</dc:date>
    </item>
  </channel>
</rss>

