<?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: SAS sql not counting null values in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-sql-not-counting-null-values/m-p/179452#M13728</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here count function count row number of dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 31 May 2014 05:04:05 GMT</pubDate>
    <dc:creator>slchen</dc:creator>
    <dc:date>2014-05-31T05:04:05Z</dc:date>
    <item>
      <title>SAS sql not counting null values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-sql-not-counting-null-values/m-p/179449#M13725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select COL1, count(distinct COL2 ) as cnt from TBL group by COL1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;If TBL contains:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;col1&amp;nbsp; col2&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XX&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then my output says:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;col1&amp;nbsp; cnt&lt;/P&gt;&lt;P&gt;A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the cnt should be 2. Why is it neglecting the null value?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 May 2014 02:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-sql-not-counting-null-values/m-p/179449#M13725</guid>
      <dc:creator>eagles_dare13</dc:creator>
      <dc:date>2014-05-31T02:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: SAS sql not counting null values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-sql-not-counting-null-values/m-p/179450#M13726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Count function in proc sql only count nonmissing value of column.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 May 2014 02:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-sql-not-counting-null-values/m-p/179450#M13726</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2014-05-31T02:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS sql not counting null values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-sql-not-counting-null-values/m-p/179451#M13727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This will include null value also&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select col1,count(*) from have&lt;/P&gt;&lt;P&gt;group by col1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 May 2014 02:35:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-sql-not-counting-null-values/m-p/179451#M13727</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-05-31T02:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS sql not counting null values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-sql-not-counting-null-values/m-p/179452#M13728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here count function count row number of dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 May 2014 05:04:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-sql-not-counting-null-values/m-p/179452#M13728</guid>
      <dc:creator>slchen</dc:creator>
      <dc:date>2014-05-31T05:04:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS sql not counting null values</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-sql-not-counting-null-values/m-p/179453#M13729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;set a value to missing value if you need it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;
data TBL;
input col1 $&amp;nbsp; col2 $;
cards;
A&amp;nbsp;&amp;nbsp;&amp;nbsp; .
A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XX
;
run;

proc sql;
select COL1, count(distinct&amp;nbsp; coalescec(COL2,'......' )) as cnt from TBL group by COL1;
select COL1, (count(distinct COL2)+(sum(missing(col2)) ne 0)) as cnt from TBL group by COL1;

quit;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: xia keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 May 2014 06:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-sql-not-counting-null-values/m-p/179453#M13729</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-05-31T06:22:37Z</dc:date>
    </item>
  </channel>
</rss>

