<?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: prevent reading blank rows in csvs in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333269#M9822</link>
    <description>&lt;P&gt;I think you mean _INFILE_, not _input_&lt;/P&gt;</description>
    <pubDate>Thu, 16 Feb 2017 04:01:13 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-02-16T04:01:13Z</dc:date>
    <item>
      <title>prevent reading blank rows in csvs</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333123#M9813</link>
      <description>&lt;P&gt;I am using the following code to read multiple csvs.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/faq/multi_file_read.htm" target="_blank"&gt;http://www.ats.ucla.edu/stat/sas/faq/multi_file_read.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;But, my csvs have blank rows in them.&amp;nbsp; Any suggestions on how to modify this code to prevent reading the blank rows.&amp;nbsp;The blank rows are making it take a&amp;nbsp;long time to run.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I am currently doing it using a second data step with this line of code&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;if compress(cats(of _all_),&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'.'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;' '&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; then delete;&lt;/FONT&gt; /*This line was also taken from SAS communites.&amp;nbsp; Thanks!*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 19:30:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333123#M9813</guid>
      <dc:creator>proctice</dc:creator>
      <dc:date>2017-02-15T19:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: prevent reading blank rows in csvs</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333144#M9814</link>
      <description>&lt;P&gt;It could make a difference depending on the file system and structure of the CSV files themselves, but you could try something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if reclen &amp;lt; 2 then
   delete;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you've used the&amp;nbsp;&lt;EM&gt;length=reclen&lt;/EM&gt; keyword of&amp;nbsp;&lt;EM&gt;infile&lt;/EM&gt;, and your files have variable length records, the blank lines will have a length of 0 or 1 (probably the former).&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 20:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333144#M9814</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-02-15T20:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: prevent reading blank rows in csvs</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333147#M9815</link>
      <description>&lt;P&gt;LaurieF,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where would I put this piece of code in the code in the link?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 20:29:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333147#M9815</guid>
      <dc:creator>proctice</dc:creator>
      <dc:date>2017-02-15T20:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: prevent reading blank rows in csvs</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333152#M9816</link>
      <description>&lt;P&gt;It's hard to tell, because I can't see your exact code!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's exactly as the link has it, I'd modify it to this:&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;do while(not done);
    myfilename = filepath;
    input @;
    if reclen &amp;gt;= 2 then do;
       input name $  x1 x2 x3 @;
       output;
       end;
    input;
  end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;&lt;EM&gt;input&lt;/EM&gt;&amp;nbsp;@; will read the record but not process it and not release it; nevertheless it populates&amp;nbsp;&lt;EM&gt;reclen&lt;/EM&gt;. If the length is 2 or more, read the fields you want and write out an observation. Again the trailing&amp;nbsp;&lt;EM&gt;&amp;nbsp;@&amp;nbsp;&lt;/EM&gt;will not release the record. At the end of the&amp;nbsp;&lt;EM&gt;do&lt;/EM&gt; block, the record is again processed as a null process, but releases it so that the&amp;nbsp;&lt;EM&gt;next&lt;/EM&gt; input will carry on correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I should think that this will give you quite an improvement, especially if you've got a lot of variables to read.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 20:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333152#M9816</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-02-15T20:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: prevent reading blank rows in csvs</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333167#M9817</link>
      <description>&lt;P&gt;When using the INPUT statement the automatic variable _INFILE_ gets created. This variable points to the input buffer.&lt;/P&gt;
&lt;P&gt;For an blank line in your source .csv the input buffer will be "blank"&amp;nbsp;and the following code should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dirlist;
  length fname $256;
  infile dirlist length=reclen;
  input fname $varying256. reclen;
  if missing(&lt;SPAN&gt;_INFILE_&lt;/SPAN&gt;) then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 04:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333167#M9817</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-02-16T04:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: prevent reading blank rows in csvs</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333269#M9822</link>
      <description>&lt;P&gt;I think you mean _INFILE_, not _input_&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 04:01:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333269#M9822</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-02-16T04:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: prevent reading blank rows in csvs</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333271#M9823</link>
      <description>&lt;P&gt;I do and fixed in&amp;nbsp;my post. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Feb 2017 04:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/prevent-reading-blank-rows-in-csvs/m-p/333271#M9823</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-02-16T04:10:08Z</dc:date>
    </item>
  </channel>
</rss>

