<?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: Checking for null values in the first row of a CSV-file in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Checking-for-null-values-in-the-first-row-of-a-CSV-file/m-p/132918#M1857</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;' first row in the CSV-file contains NULL-values'&lt;/P&gt;&lt;P&gt;Is that a totally empty row? So 0 to n blanks and a end-of-line indicator? Or do you have the field delimiters in it but all values are "NULL"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below untested code providing a sample of how you could do it for either of the 2 cases:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let Empty_Line_Flag=0;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile &amp;lt;yourfile&amp;gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* only 0 to n blanks */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if missing(_infile_) then call symputx('Empty_Line_Flag','1');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* only delimiters and 0 to n blanks */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prxmatch('/[^, ]/oi',_infile_) = 0 then call symputx('Empty_Line_Flag','1');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* stop: so only reading first line */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... and then send an email if &amp;amp;Empty_Line_Flag=1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Nov 2013 23:42:54 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2013-11-05T23:42:54Z</dc:date>
    <item>
      <title>Checking for null values in the first row of a CSV-file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Checking-for-null-values-in-the-first-row-of-a-CSV-file/m-p/132915#M1854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd like to set up a user written transformation which reads a CSV-file and sends me an email IF the first row in the CSV-file contains NULL-values. The code for sending the email is ready, but I'd appreciate help with the rest, because the way I'm doing it seems very convoluted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone please suggest the most "short and sweet" SAS code for simply reading the first row of a CSV-file and checking if it contains NULL-values?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Nov 2013 14:44:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Checking-for-null-values-in-the-first-row-of-a-CSV-file/m-p/132915#M1854</guid>
      <dc:creator>EinarRoed</dc:creator>
      <dc:date>2013-11-05T14:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for null values in the first row of a CSV-file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Checking-for-null-values-in-the-first-row-of-a-CSV-file/m-p/132916#M1855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Depends upon what you refer to as null values and how your file is structured.&amp;nbsp; If each of your input records capture all of the information for one person/item/date or whatever they represent, and you simply want to discover if there are any characters in that record besides commas and spaces, you could simply include a "if _n_ eq 1 then input @;" statement, compress out all of the commas and blanks from _infile_, and then check the length of the stripped _infile_ variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Nov 2013 14:58:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Checking-for-null-values-in-the-first-row-of-a-CSV-file/m-p/132916#M1855</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2013-11-05T14:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for null values in the first row of a CSV-file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Checking-for-null-values-in-the-first-row-of-a-CSV-file/m-p/132917#M1856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure what you mean as the first row of a CSV file is normally interpreted as the column names.&lt;/P&gt;&lt;P&gt;You can use the COUNTW() function with and without the M modifier to check if there are empty values.&amp;nbsp; But that would treat a value that is all spaces as NOT empty.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input @;&lt;/P&gt;&lt;P&gt;&amp;nbsp; n1 = countw(_infile_,',','MQ');&lt;/P&gt;&lt;P&gt;&amp;nbsp; n2 = countw(_infile_,',','Q');&lt;/P&gt;&lt;P&gt;&amp;nbsp; put n1= n2= +1 _infile_;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;1,2,3&lt;/P&gt;&lt;P&gt;1,,3&lt;/P&gt;&lt;P&gt;1, ,3&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Nov 2013 15:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Checking-for-null-values-in-the-first-row-of-a-CSV-file/m-p/132917#M1856</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-11-05T15:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Checking for null values in the first row of a CSV-file</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Checking-for-null-values-in-the-first-row-of-a-CSV-file/m-p/132918#M1857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;' first row in the CSV-file contains NULL-values'&lt;/P&gt;&lt;P&gt;Is that a totally empty row? So 0 to n blanks and a end-of-line indicator? Or do you have the field delimiters in it but all values are "NULL"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below untested code providing a sample of how you could do it for either of the 2 cases:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let Empty_Line_Flag=0;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile &amp;lt;yourfile&amp;gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* only 0 to n blanks */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if missing(_infile_) then call symputx('Empty_Line_Flag','1');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* only delimiters and 0 to n blanks */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if prxmatch('/[^, ]/oi',_infile_) = 0 then call symputx('Empty_Line_Flag','1');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* stop: so only reading first line */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; stop;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... and then send an email if &amp;amp;Empty_Line_Flag=1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Nov 2013 23:42:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Checking-for-null-values-in-the-first-row-of-a-CSV-file/m-p/132918#M1857</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-11-05T23:42:54Z</dc:date>
    </item>
  </channel>
</rss>

