<?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: Multiple Having clauses in sas in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-Having-clauses-in-sas/m-p/175280#M44989</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Or if the goal was to actually only output the line for &lt;SPAN style="background: none repeat scroll 0% 0% white; color: black;"&gt;&lt;SPAN style="background: none repeat scroll 0% 0% white; color: black;"&gt;FSDILX 52 $52,000&lt;/SPAN&gt; then you could specify them in the having statement, otherwise the way the code is currently written I agree with ballardw, proc sql will get mad because you are asking about having something, but not specifying what you want it to have. &lt;/SPAN&gt;For reference if you wanted the line you had specified earlier you could use this as the having statement&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;having &lt;SPAN style="background: none repeat scroll 0% 0% white; color: black;"&gt;comm_cd = "FSDILX" and &lt;/SPAN&gt;&lt;SPAN style="background: none repeat scroll 0% 0% white; color: black;"&gt;count(ln_no) = 52 and &lt;SPAN style="background: none repeat scroll 0% 0% white; color: black;"&gt;sum(balance) = 52000;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 15 Feb 2014 15:35:35 GMT</pubDate>
    <dc:creator>overmar</dc:creator>
    <dc:date>2014-02-15T15:35:35Z</dc:date>
    <item>
      <title>Multiple Having clauses in sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-Having-clauses-in-sas/m-p/175278#M44987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;sql&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; FSDILX2 &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; comm_cd,count(ln_no) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; ln,sum(balance) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; bal&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; FSDILX1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;group&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; comm_cd&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;having&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; count(ln_no) &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; sum(bal);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;STRONG style="color: navy; background: white; font-family: 'Courier New';"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;Obviously this is wrong.&amp;nbsp; I am trying to get output in a summary form something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;FSDILX (which is a comm_cd)&amp;nbsp; 52 (which is the total loan numbers or ln_no)&amp;nbsp; $52,000 (which is the total balance or bal)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;Would I need two separate proc statements for the count and the sum?&amp;nbsp; Can I combine into one statement?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 20:18:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-Having-clauses-in-sas/m-p/175278#M44987</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2014-02-14T20:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Having clauses in sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-Having-clauses-in-sas/m-p/175279#M44988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Having clauses are usually used to restrict the output to some range. I suspect you don't need one from the description of your output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I wanted to restrict the output to a minimum number of ln_no I would add:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Having count(ln_no) &amp;gt; 15&lt;/P&gt;&lt;P&gt;or a maximum total balance with:&lt;/P&gt;&lt;P&gt;Having sum(balance) &amp;lt;10000&lt;/P&gt;&lt;P&gt;and to apply both restricts use AND&lt;/P&gt;&lt;P&gt;Having count(*) &amp;gt; 15 and sum(balance)&amp;lt;10000&lt;/P&gt;&lt;P&gt;for example.&lt;/P&gt;&lt;P&gt;For count probably don't even need a variable: count(*) will give a count of records with in group of comm_cd.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Feb 2014 21:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-Having-clauses-in-sas/m-p/175279#M44988</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-02-14T21:25:21Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Having clauses in sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-Having-clauses-in-sas/m-p/175280#M44989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Or if the goal was to actually only output the line for &lt;SPAN style="background: none repeat scroll 0% 0% white; color: black;"&gt;&lt;SPAN style="background: none repeat scroll 0% 0% white; color: black;"&gt;FSDILX 52 $52,000&lt;/SPAN&gt; then you could specify them in the having statement, otherwise the way the code is currently written I agree with ballardw, proc sql will get mad because you are asking about having something, but not specifying what you want it to have. &lt;/SPAN&gt;For reference if you wanted the line you had specified earlier you could use this as the having statement&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;having &lt;SPAN style="background: none repeat scroll 0% 0% white; color: black;"&gt;comm_cd = "FSDILX" and &lt;/SPAN&gt;&lt;SPAN style="background: none repeat scroll 0% 0% white; color: black;"&gt;count(ln_no) = 52 and &lt;SPAN style="background: none repeat scroll 0% 0% white; color: black;"&gt;sum(balance) = 52000;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 15 Feb 2014 15:35:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-Having-clauses-in-sas/m-p/175280#M44989</guid>
      <dc:creator>overmar</dc:creator>
      <dc:date>2014-02-15T15:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Having clauses in sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-Having-clauses-in-sas/m-p/175281#M44990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe I'm missing something obvious here, but I would just get rid of the having clause, and add distinct in the count...?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Feb 2014 12:08:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-Having-clauses-in-sas/m-p/175281#M44990</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2014-02-16T12:08:24Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Having clauses in sas</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiple-Having-clauses-in-sas/m-p/175282#M44991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to reference the source variable BALANCE and not the derived variable BAL in the HAVING clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also it does depend on the way that SAS evaluates numbers in boolean expressions.&lt;/P&gt;&lt;P&gt;I think you want:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;having&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: black;"&gt; count(ln_no)&amp;gt;0 &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'Courier New'; color: blue;"&gt;and not (&lt;/SPAN&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-style: inherit; font-weight: inherit; font-size: 10pt; line-height: 1.5em;"&gt;sum(balance)=0) &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="color: black; font-family: 'Courier New'; font-style: inherit; font-weight: inherit; font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 16 Feb 2014 18:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiple-Having-clauses-in-sas/m-p/175282#M44991</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-02-16T18:05:56Z</dc:date>
    </item>
  </channel>
</rss>

