<?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: Group by / Having statement in SQL in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337961#M76834</link>
    <description>&lt;P&gt;Do you see the difference between &lt;STRONG&gt;&lt;FONT color="#800080" face="Courier New" size="4"&gt;"CARD"&lt;/FONT&gt;&lt;/STRONG&gt; and card in your example data? Text comparisons are case sensitive&lt;/P&gt;</description>
    <pubDate>Fri, 03 Mar 2017 18:51:05 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-03-03T18:51:05Z</dc:date>
    <item>
      <title>Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337912#M76818</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use the &lt;U&gt;Group by / Having&lt;/U&gt; statement&amp;nbsp; to filter a data set. This is what I am trying to do:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1. PROD_DESCRIPTION is not empty&lt;/P&gt;&lt;P&gt;2. ACCT_NAME contains "CARD" and have the lastest update_time in this variable&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Somehow, it only generated the list with PROD_DESCRIPTION is not empty, and the second condition did not get caught, but I am sure there are some that satisifies the condition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code looks like following, please help. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="4"&gt;&lt;STRONG&gt;PROC&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="4"&gt;SQL&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="4"&gt;; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;CREATE&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="4"&gt;TABLE&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; test2 &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;AS&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;SELECT&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008080" face="Courier New" size="4"&gt;t1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;*&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;FROM&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;&amp;nbsp;test1 t1 &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="4"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; ID&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;having&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; (PROD_DESCRIPTION ne &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="4"&gt;""&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&amp;nbsp; or&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; (ACCT_NAME &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;contains&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="4"&gt;"CARD"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="4"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; UPDATE_TIME = MAX(UPDATE_TIME)))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="4"&gt;&lt;STRONG&gt;QUIT&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 17:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337912#M76818</guid>
      <dc:creator>肉肉</dc:creator>
      <dc:date>2017-03-03T17:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337923#M76826</link>
      <description>&lt;P&gt;It helps to provide some example data that shows some of the records you expect to see in the result but don't get. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also have you tried&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;having&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; not missing(PROD_DESCRIPTION)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&amp;nbsp; or&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; (ACCT_NAME &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;contains&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="4"&gt;"CARD"&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="4"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; UPDATE_TIME = MAX(UPDATE_TIME))&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 17:35:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337923#M76826</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-03T17:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337952#M76831</link>
      <description>&lt;P&gt;Thank you for ur reply. the code you presented in your reply did not help. it had the same result as my original code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lets have an example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PROD_DESCRIPTION&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ACCT_Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Update_Time&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pen&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;pen&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jul2014&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cup&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cup&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; May2014&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; card&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jun2015&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; card&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Jan2016&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;From&amp;nbsp;my code, the result only shows the first two row, but I want to get 1st, 2nd and 4th row.&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 18:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337952#M76831</guid>
      <dc:creator>肉肉</dc:creator>
      <dc:date>2017-03-03T18:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337961#M76834</link>
      <description>&lt;P&gt;Do you see the difference between &lt;STRONG&gt;&lt;FONT color="#800080" face="Courier New" size="4"&gt;"CARD"&lt;/FONT&gt;&lt;/STRONG&gt; and card in your example data? Text comparisons are case sensitive&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 18:51:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337961#M76834</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-03T18:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337963#M76835</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sorry it was a typo. In my data, it was upper case as 'CARD', but it did not help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but thank you for point it out.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 18:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337963#M76835</guid>
      <dc:creator>肉肉</dc:creator>
      <dc:date>2017-03-03T18:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337991#M76838</link>
      <description>&lt;P&gt;Without data to test on it can be difficult to determine where actual results are. Use of CONTAINS seems to be problematic and may be padding the variable to length such that "CARD" is not equal to "CARD&amp;nbsp;&amp;nbsp;&amp;nbsp; " or similar, especially if using code developed in another SQL as a pattern.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest also trying&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;having&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; not missing(PROD_DESCRIPTION)&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;&amp;nbsp; or&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; (index(ACCT_NAME,&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="4"&gt;"CARD")&amp;gt;0&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="4"&gt;and&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; UPDATE_TIME = MAX(UPDATE_TIME))&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or use STRIP(acct_name) in the contains clause.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also confirm that your UPDATE_TIME is a SAS time or Datetime variable. If the values are character then the MAX function likely doesn't like it though an error may not result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can provide data for us to use based on your dataset. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;Or a dummy dataset with the same variables and values that duplicate the behavior&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 20:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337991#M76838</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-03T20:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337996#M76839</link>
      <description>&lt;P&gt;I get the expected result with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test1;
input ID PROD_DESCRIPTION $ ACCT_Name :$8. t :$7.;
Update_Time = input(cats("01",t), date9.);
format Update_Time yymmdd10.;
datalines;
1         PEN    PEN    JUL2014
1         CUP    CUP    MAY2014
1         .      CARD   JUN2015
1         .      CARD   JAN2016
;

PROC SQL;
CREATE TABLE test2 AS
SELECT
    t1.*
FROM test1 as t1
group by ID
having PROD_DESCRIPTION is not missing or
  ACCT_NAME contains "CARD" and UPDATE_TIME = MAX(UPDATE_TIME);
select * from test2;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Mar 2017 20:20:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/337996#M76839</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-03-03T20:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338013#M76845</link>
      <description>&lt;P&gt;Thank you, it worked. but it gives me in the "Result" tab, but in the "Output Data" tab. By the way, I am using SAS Enterprise Guide 6.1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need this to be under "Output Data" tab, as i need&amp;nbsp;to&amp;nbsp;do&amp;nbsp;further process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not too sure if your SAS version. Hope you can help further. Thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 21:08:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338013#M76845</guid>
      <dc:creator>肉肉</dc:creator>
      <dc:date>2017-03-03T21:08:06Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338020#M76847</link>
      <description>&lt;P&gt;Thank you again for help me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the "UPDATE_TIME" is in Date/Time format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One thing I need to point out is, keep the condition &amp;nbsp;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;having&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; not missing(PROD_DESCRIPTION)&lt;/FONT&gt;,&lt;/P&gt;&lt;P&gt;1. if I just add one condition which is ACCT_NAME contains &lt;SPAN class="token string"&gt;"CARD", it worked.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token punctuation"&gt;2. if I just add one condition which is UPDATE_TIME &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;MAX&lt;/SPAN&gt;(UPDATE_TIME), it worked too.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token punctuation"&gt;but when I add both of them together, it did not work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="token punctuation"&gt;I am so confused.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 21:22:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338020#M76847</guid>
      <dc:creator>肉肉</dc:creator>
      <dc:date>2017-03-03T21:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338021#M76848</link>
      <description>because of what I do, I could not share the data set. its little touchy...sorry. but thank you for recommending.</description>
      <pubDate>Fri, 03 Mar 2017 21:24:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338021#M76848</guid>
      <dc:creator>肉肉</dc:creator>
      <dc:date>2017-03-03T21:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338032#M76851</link>
      <description>&lt;P&gt;dummy data that has the same data characteristics, lengths, types and formats of variables is sufficient as long as it duplicates the behavior you observe and can be manipulated to generate the desired results. Such as looking for CARD vs card.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 21:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338032#M76851</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-03T21:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338052#M76857</link>
      <description>&lt;P&gt;Yes, that can be done.&amp;nbsp; let me work on this over the weekend, if I still had problem, I would consult you. Thank you again, have a nice weekend.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 22:26:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338052#M76857</guid>
      <dc:creator>肉肉</dc:creator>
      <dc:date>2017-03-03T22:26:23Z</dc:date>
    </item>
    <item>
      <title>Re: Group by / Having statement in SQL</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338057#M76859</link>
      <description>&lt;P&gt;You should be getting both version of the output. I am not a user of EG interface, but my guess is: CREATE TABLE TEST2 AS creates the TEST2 dataset in the WORK library (Output data) and SELECT * FROM TEST2; prints the contents of TEST2 in the Results. That last statement is just there for your convenience, it is not required.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Further processing should use the TEST2 dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 22:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-Having-statement-in-SQL/m-p/338057#M76859</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-03-03T22:39:09Z</dc:date>
    </item>
  </channel>
</rss>

