<?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: Reading data from multiple files in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141129#M37670</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Tom,&lt;/P&gt;&lt;P&gt;Thank you for your quick answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I modified that section and it work perfectly!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Mar 2014 15:40:42 GMT</pubDate>
    <dc:creator>BchBnz</dc:creator>
    <dc:date>2014-03-12T15:40:42Z</dc:date>
    <item>
      <title>Reading data from multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141126#M37667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Hello everyone,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I hope you are all well.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I have an issue with reading multiple data files in SAS. I tried many methods but it is not working.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Here is an example of the code that I used. It worked with .txt files but I tried only with 5 files.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Method 1:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;%let dirname = E:\Data\Lisbon;&lt;/P&gt;&lt;P&gt;filename DIRLIST pipe "dir /B &amp;amp;dirname\*.tas";&lt;/P&gt;&lt;P&gt;data dirlist ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length fname $256; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile dirlist length=reclen ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input fname $varying256. reclen ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data all_tas_lisbon (drop=fname);&lt;/P&gt;&lt;P&gt;&amp;nbsp; length myfilename $100;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length name $25;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set dirlist;&lt;/P&gt;&lt;P&gt;&amp;nbsp; filepath = "&amp;amp;dirname\"||fname;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile dummy filevar = filepath length=reclen end=done DSD dlm= ',' TRUNCOVER;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do while(not done);&lt;/P&gt;&lt;P&gt;&amp;nbsp; myfilename = filepath;&lt;/P&gt;&lt;P&gt;length date 8 time 8 cpf $1 cnt $3 ba $1;&lt;/P&gt;&lt;P&gt;informat date ED yymmdd8. time time8.;&lt;/P&gt;&lt;P&gt;format date ED yymmdd10. time time8.;&lt;/P&gt;&lt;P&gt;retain date;&lt;/P&gt;&lt;P&gt;if _n_=1 then do;&lt;/P&gt;&lt;P&gt;input //date//;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;input time cpf $ cnt $ ED vol ba $ price var1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;The data was incomplete and there is what I read on the log window:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NOTE: Variable name is uninitialized.&lt;/P&gt;&lt;P&gt;NOTE: The infile DUMMY is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Filename=E:\Data\Lisbon\s_equities_20080101.tas,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RECFM=V,LRECL=256,File Size (bytes)=60,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Last Modified=04 March 2008 11:10:46 o'clock,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create Time=11 March 2014 22:27:05 o'clock&lt;/P&gt;&lt;P&gt;NOTE: LOST CARD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Thank you in advance for your precious time and help.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 14:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141126#M37667</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-03-12T14:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141127#M37668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The IF _N_=1 will not work in this case as that will apply only to the first filename they you read from the dataset DIRLIST.&lt;/P&gt;&lt;P&gt;You can fix that by changing the DO loop.&amp;nbsp; Also note the RETAIN is not needed as you are reading the whole file in one iteration of the data step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;myfilename = filepath;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; date &lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; time &lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;8&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; cpf $&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; cnt $&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ba $&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;informat&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; date ED &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;yymmdd8.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; time &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;time8.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; date ED &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;yymmdd10.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; time &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;time8.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; _n_=&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;by &lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1 &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;while&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; (not done);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; _n_=&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; //date//;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; time cpf $ cnt $ ED vol ba $ price var1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 15:13:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141127#M37668</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-03-12T15:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141128#M37669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like the program creates FNAME, not NAME.&amp;nbsp; Did you expect NAME to contain any information?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Tom's approach looks good, although I would simplify the DO loop to look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;input // date //;&lt;/P&gt;&lt;P&gt;do until (done);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; input time cpf $ cnt $ ED vol ba $ price var1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 15:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141128#M37669</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-03-12T15:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141129#M37670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Tom,&lt;/P&gt;&lt;P&gt;Thank you for your quick answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I modified that section and it work perfectly!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 15:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141129#M37670</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-03-12T15:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141130#M37671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Astounding,&lt;/P&gt;&lt;P&gt;The NAME variable is just a mistake! My bad!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried your code as well and it work just fine.&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 15:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141130#M37671</guid>
      <dc:creator>BchBnz</dc:creator>
      <dc:date>2014-03-12T15:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reading data from multiple files</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141131#M37672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think @tom use WHILE to prevent lost card message in case the file is empty.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 15:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Reading-data-from-multiple-files/m-p/141131#M37672</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-03-12T15:57:44Z</dc:date>
    </item>
  </channel>
</rss>

