<?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 all text files into one dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Read-all-text-files-into-one-dataset/m-p/371087#M88645</link>
    <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32"&gt;@BrunoMueller&lt;/a&gt;&amp;nbsp;, i tried your code, made very small changes and it works! I was able to pull in several flat files as i was hoping for.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Jun 2017 23:10:20 GMT</pubDate>
    <dc:creator>rajneelram87</dc:creator>
    <dc:date>2017-06-27T23:10:20Z</dc:date>
    <item>
      <title>Read all text files into one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-all-text-files-into-one-dataset/m-p/196447#M36893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have got several txt files on unix platform. Names are different but structure is same. I need to create only one dataset of all these files and that should have data from all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My below one datastep works fine but i am unable to somehow get all files together in one dataset.&amp;nbsp; and I also want one column which says the name of the text file from which this data is coming&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data new;&lt;/P&gt;&lt;P&gt;infile "/gpfs1/ana_layer/file1.txt' ;&lt;/P&gt;&lt;P&gt;input @1 id $3 @5 age;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this works correctly for one file but i am unable to generalise it for the entire directory and also unable to get the filename as one more column in the resultant dataset&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2015 12:46:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-all-text-files-into-one-dataset/m-p/196447#M36893</guid>
      <dc:creator>yashpande</dc:creator>
      <dc:date>2015-04-15T12:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: Read all text files into one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-all-text-files-into-one-dataset/m-p/196448#M36894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are at least 30 separate topics using a variety of methods on these forums.&amp;nbsp; Just search for "read multiple files from directory".&lt;/P&gt;&lt;P&gt;Example: &lt;A __default_attr="100163" __jive_macro_name="message" class="jive_macro jive_macro_message" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2015 13:03:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-all-text-files-into-one-dataset/m-p/196448#M36894</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-04-15T13:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: Read all text files into one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-all-text-files-into-one-dataset/m-p/196449#M36895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the INFILE statement supports wildcards, the FILENAME= option names a variable that will contain the name of the file that a records was read from. Please note, that the variable named by the FILENAME= option is dropped automatically, so you need to assign the value to some other variable. See also example 5 in the doc for more ideas on the list of files to read &lt;A href="http://support.sas.com/documentation/cdl/en/lestmtsref/67407/HTML/default/viewer.htm#n1rill4udj0tfun1fvce3j401plo.htm" title="http://support.sas.com/documentation/cdl/en/lestmtsref/67407/HTML/default/viewer.htm#n1rill4udj0tfun1fvce3j401plo.htm"&gt;SAS(R) 9.4 Statements: Reference, Third Edition&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; someData;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; _xFilename $ &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;256&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"c:\temp\*.csv"&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;filename&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=_xfilename;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; xFilename = _xFilename;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; line &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$10.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;bruno&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2015 13:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-all-text-files-into-one-dataset/m-p/196449#M36895</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2015-04-15T13:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Read all text files into one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-all-text-files-into-one-dataset/m-p/196450#M36896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let path=where_your_file_are_stored;&lt;/P&gt;&lt;P&gt;%let filnam=common_part_of_filename;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename oscmd pipe "ls &amp;amp;path./&amp;amp;filnam.*";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;infile oscmd;&lt;/P&gt;&lt;P&gt;length filnam myfilename filnamstore $ 300;&lt;/P&gt;&lt;P&gt;input filnam;&lt;/P&gt;&lt;P&gt;infile in filevar=filnam filename=myfilename end=done;&lt;/P&gt;&lt;P&gt;do while (not done);&lt;/P&gt;&lt;P&gt;&amp;nbsp; *read external file as usual;&lt;/P&gt;&lt;P&gt;&amp;nbsp; filnamstore=myfilename;&lt;/P&gt;&lt;P&gt;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Built upon the example in &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/a000146932.htm#a000177201" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/a000146932.htm#a000177201"&gt;Statements: INFILE Statement - 9.2&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Apr 2015 13:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-all-text-files-into-one-dataset/m-p/196450#M36896</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-04-15T13:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: Read all text files into one dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-all-text-files-into-one-dataset/m-p/371087#M88645</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32"&gt;@BrunoMueller&lt;/a&gt;&amp;nbsp;, i tried your code, made very small changes and it works! I was able to pull in several flat files as i was hoping for.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 23:10:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-all-text-files-into-one-dataset/m-p/371087#M88645</guid>
      <dc:creator>rajneelram87</dc:creator>
      <dc:date>2017-06-27T23:10:20Z</dc:date>
    </item>
  </channel>
</rss>

