<?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: Count with Where in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135463#M10963</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, I did it exactly like you have it and is running.&amp;nbsp; The only problems is that the table is created with the right column name, but is empty.&amp;nbsp; Any idea why?&amp;nbsp; I know I should have around 5 million records showing up, but none right now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Jan 2014 03:05:19 GMT</pubDate>
    <dc:creator>ismahero2</dc:creator>
    <dc:date>2014-01-09T03:05:19Z</dc:date>
    <item>
      <title>Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135457#M10957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have a table like this one:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Header 1&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Header 2&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Header 3&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;999&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;454565&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;5654&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;996&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;gdrgr&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;egdg&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;996&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;df&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;dgfd&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;999&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;df&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;xd&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;555&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;dfd&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;ff&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;444&lt;/TD&gt;&lt;TD&gt;fef&lt;/TD&gt;&lt;TD&gt;fe&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;333&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, I want to create a table with only the rows in column "Header 1" where there is a distinct record.&amp;nbsp; The resulting table should be something like this:&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" height="99" style="border: 1px solid rgb(0, 0, 0); width: 190px; height: 57px;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;UniqueNumbers&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;555&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;444&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;333&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to do a Count but I am having problems selecting Where Count=1.&amp;nbsp;&amp;nbsp; Any ideas?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 00:05:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135457#M10957</guid>
      <dc:creator>ismahero2</dc:creator>
      <dc:date>2014-01-09T00:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135458#M10958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need it to be in the having rather than the where. Where is for when reading things in, having can be used once things have been calculated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select distinct (header_1) as uniquenumbers&lt;/P&gt;&lt;P&gt;from table&lt;/P&gt;&lt;P&gt;having (count(header_1)) = 1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 00:30:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135458#M10958</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-01-09T00:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135459#M10959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think this one will work, but for now is giving me this error:&lt;/P&gt;&lt;P&gt;Sintax error, expecting one of the following: (, SELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea what I am missing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 00:53:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135459#M10959</guid>
      <dc:creator>ismahero2</dc:creator>
      <dc:date>2014-01-09T00:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135460#M10960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the full code that you had written? Because right now this doesn't make much sense.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 00:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135460#M10960</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-01-09T00:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135461#M10961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, this is the exact code I have.&amp;nbsp;&amp;nbsp; MyTable is the name of the new table I will create and Originaltable is the table where the data comes from.&amp;nbsp;&amp;nbsp; Hope you can help me..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table MyTable as;&lt;/P&gt;&lt;P&gt;select distinct ('header_1') as uniquenumbers&lt;/P&gt;&lt;P&gt;from Originaltable&lt;/P&gt;&lt;P&gt;having (count('header_1')) = 1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 02:37:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135461#M10961</guid>
      <dc:creator>ismahero2</dc:creator>
      <dc:date>2014-01-09T02:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135462#M10962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forgot to suggest an addition of group by to the earlier code and do not put a semi-colon after as, this stops sas the semi-colon should go at the end of the proc sql statement (in this case after having). This is why it was giving you a "select" error, bc you had ended the code before you had given it a select statement. This code should now sufficiently run:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table MyTable as&lt;/P&gt;&lt;P&gt;select distinct ('header_1') as uniquenumbers&lt;/P&gt;&lt;P&gt;from Originaltable&lt;/P&gt;&lt;P&gt;group by header_1&lt;/P&gt;&lt;P&gt;having (count('header_1')) = 1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 02:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135462#M10962</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-01-09T02:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135463#M10963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, I did it exactly like you have it and is running.&amp;nbsp; The only problems is that the table is created with the right column name, but is empty.&amp;nbsp; Any idea why?&amp;nbsp; I know I should have around 5 million records showing up, but none right now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your time.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 03:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135463#M10963</guid>
      <dc:creator>ismahero2</dc:creator>
      <dc:date>2014-01-09T03:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135464#M10964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry I didn't read your code all the way through and it appears that you put ' around the column names, if you do that proc sql thinks that this is a character string rather than a column name, so take those out for the code to run, final code would be:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table MyTable as&lt;/P&gt;&lt;P&gt;select distinct (header_1) as uniquenumbers&lt;/P&gt;&lt;P&gt;from Originaltable&lt;/P&gt;&lt;P&gt;group by header_1&lt;/P&gt;&lt;P&gt;having (count(header_1)) = 1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 03:11:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135464#M10964</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-01-09T03:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135465#M10965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wouldn't use "distinct". Code like below should do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: rgba(255, 255, 255, 0);"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: rgba(255, 255, 255, 0);"&gt;create table MyTable as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: rgba(255, 255, 255, 0);"&gt;select header_1 as uniquenumbers&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: rgba(255, 255, 255, 0);"&gt;from Originaltable&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: rgba(255, 255, 255, 0);"&gt;group by header_1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: rgba(255, 255, 255, 0);"&gt;having count(header_1) = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: rgba(255, 255, 255, 0);"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 09:28:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135465#M10965</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-01-09T09:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135466#M10966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Odd question, I tend to use select distinct on just about everything that I do. Many time regardless if I use a summary function, at this point I think its a force of habit. Other than the possibility of losing duplicate records am I causing any other specific issues for myself? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 16:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135466#M10966</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-01-09T16:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135467#M10967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You guys like SQL so much?&amp;nbsp; How about this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sort by header1 first, then if first.header1 and last.header1.&amp;nbsp; Using data step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 16:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135467#M10967</guid>
      <dc:creator>WilliamWei</dc:creator>
      <dc:date>2014-01-09T16:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135468#M10968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;overmar,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For this particular problem, you get the wrong answer if you add DISTINCT.&amp;nbsp; The COUNT will always be 1 when you examine:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;group by header_1&lt;/P&gt;&lt;P&gt;having count (distinct header_1)=1&lt;/P&gt;&lt;P&gt;For every value of HEADER_1, there is only a single distinct value of HEADER_1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 19:17:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135468#M10968</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-01-09T19:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: Count with Where</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135469#M10969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Aha, that makes sense, I would have figured it out if I had run the code, but now I will think about it before running it. Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jan 2014 19:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Count-with-Where/m-p/135469#M10969</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-01-09T19:51:30Z</dc:date>
    </item>
  </channel>
</rss>

