<?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: Making sure all raw data files are accounted for in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Making-sure-all-raw-data-files-are-accounted-for/m-p/878428#M347056</link>
    <description>&lt;P&gt;You can get the filename of the infile currently being read using the FILENAME option, e.g.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data raw;
  infile 'c:\dir\*.csv' filename=fnam &amp;lt;and other options, like delimiter&amp;gt;;
  csvfile=fnam; /* the FILENAME variable is not saved to output */
  input &amp;lt;your input statement&amp;gt;;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then check against the directory you got with the pipe (or use DOPEN and DREAD, that's more portable), and see how many records came from each file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another possibility is to use the FILEVAR and EOF options to read the files - assuming the directory scan data is WORK.FILES, you can do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data raw(drop=noofrecords) linesread(keep=noofrecords &amp;lt;filename variable&amp;gt;);
  set files;
  infile dummy filevar=&amp;lt;filename variable&amp;gt; eof=done &amp;lt;and delimiters etc&amp;gt;;
  do noofrecords=0 by 1;
    input &amp;lt;your input statement&amp;gt;;
    output raw;
    end;
  done: /* EOF makes the program jump here when there are not more records */
  output linesread;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The reason why the EOF option is used here is that there will also be an output for empty files (noofrecords=0) this way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 May 2023 14:00:28 GMT</pubDate>
    <dc:creator>s_lassen</dc:creator>
    <dc:date>2023-05-31T14:00:28Z</dc:date>
    <item>
      <title>Making sure all raw data files are accounted for</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-sure-all-raw-data-files-are-accounted-for/m-p/878413#M347051</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a program which reads in 100+ CSV raw data files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a check, I'd like to set up the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An output that includes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1. The total # of raw CSV files in the directory&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2. The number of CSV files in the directory which were read in by the program&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3. Whether the resulting data file had 0 records&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know I can get at #1 using a pipe statement; less sure how to get 2 and 3 and combine them into a single output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is much appreciated.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 13:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-sure-all-raw-data-files-are-accounted-for/m-p/878413#M347051</guid>
      <dc:creator>Walternate</dc:creator>
      <dc:date>2023-05-31T13:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Making sure all raw data files are accounted for</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-sure-all-raw-data-files-are-accounted-for/m-p/878428#M347056</link>
      <description>&lt;P&gt;You can get the filename of the infile currently being read using the FILENAME option, e.g.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data raw;
  infile 'c:\dir\*.csv' filename=fnam &amp;lt;and other options, like delimiter&amp;gt;;
  csvfile=fnam; /* the FILENAME variable is not saved to output */
  input &amp;lt;your input statement&amp;gt;;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then check against the directory you got with the pipe (or use DOPEN and DREAD, that's more portable), and see how many records came from each file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another possibility is to use the FILEVAR and EOF options to read the files - assuming the directory scan data is WORK.FILES, you can do something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data raw(drop=noofrecords) linesread(keep=noofrecords &amp;lt;filename variable&amp;gt;);
  set files;
  infile dummy filevar=&amp;lt;filename variable&amp;gt; eof=done &amp;lt;and delimiters etc&amp;gt;;
  do noofrecords=0 by 1;
    input &amp;lt;your input statement&amp;gt;;
    output raw;
    end;
  done: /* EOF makes the program jump here when there are not more records */
  output linesread;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The reason why the EOF option is used here is that there will also be an output for empty files (noofrecords=0) this way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 14:00:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-sure-all-raw-data-files-are-accounted-for/m-p/878428#M347056</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2023-05-31T14:00:28Z</dc:date>
    </item>
  </channel>
</rss>

