<?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: SQL TRANSLATION in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SQL-TRANSLATION/m-p/510371#M1939</link>
    <description>&lt;P&gt;The reason you get that&amp;nbsp;&lt;STRONG&gt;Note&lt;/STRONG&gt; (not an error) is because you are selecting a variable that you are performing statistics on:&lt;/P&gt;
&lt;PRE&gt;SELECT NTDIncurredLossExclRevalUSD
&lt;/PRE&gt;
&lt;P&gt;And this:&lt;/P&gt;
&lt;PRE&gt;SUM(Claim.NTDIncurredLossExclRevalUSD) &lt;/PRE&gt;
&lt;P&gt;Are going against each other, in the latter you are grouping and summing the data, in the first you are selecting all values within that column, no grouping or summing.&amp;nbsp; You either want one or the other.&amp;nbsp; I present an example here where the sum is used:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table claimmedll as
  select claimno,
         pac,
         sum(ntdincurredlossexclrevalusd) as ntdincurredlossexclrevalusd	
  from   (select * from claim where pac="GMMAM")
  group by claimno,
           pac
  having sum(ntdincurredlossexclrevalusd) &amp;gt; 50000;
run;&lt;/PRE&gt;
&lt;P&gt;Note that I put part of the having in a sub-query, I just find it simpler to see what data feeds into the larger grouping.&amp;nbsp; As we fix pac as only one where clause, pac could be totally removed from the outer loop without changing the outcome as it will always be GMMAM.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Nov 2018 12:57:48 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-11-05T12:57:48Z</dc:date>
    <item>
      <title>SQL TRANSLATION</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-TRANSLATION/m-p/510351#M1933</link>
      <description>&lt;P&gt;HI ALL,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;does anyone know how to translate it in SAS STUDIO(WEB VERSION)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the claimno,pac are both character with the length of 15 -23&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;but it seems not able to group by&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this error keeps coming out&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NOTE: The query requires remerging summary statistics back with the original data.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table ClaimMedLL as&lt;BR /&gt;SELECT NTDIncurredLossExclRevalUSD ,pac,claimno&lt;BR /&gt;from Claim&lt;BR /&gt;GROUP BY claimno,pac&lt;BR /&gt;HAVING Claim.Pac IN ('GMMAM') and SUM(Claim.NTDIncurredLossExclRevalUSD) &amp;gt; 50000&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 10:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-TRANSLATION/m-p/510351#M1933</guid>
      <dc:creator>harrylui</dc:creator>
      <dc:date>2018-11-05T10:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: SQL TRANSLATION</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-TRANSLATION/m-p/510371#M1939</link>
      <description>&lt;P&gt;The reason you get that&amp;nbsp;&lt;STRONG&gt;Note&lt;/STRONG&gt; (not an error) is because you are selecting a variable that you are performing statistics on:&lt;/P&gt;
&lt;PRE&gt;SELECT NTDIncurredLossExclRevalUSD
&lt;/PRE&gt;
&lt;P&gt;And this:&lt;/P&gt;
&lt;PRE&gt;SUM(Claim.NTDIncurredLossExclRevalUSD) &lt;/PRE&gt;
&lt;P&gt;Are going against each other, in the latter you are grouping and summing the data, in the first you are selecting all values within that column, no grouping or summing.&amp;nbsp; You either want one or the other.&amp;nbsp; I present an example here where the sum is used:&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table claimmedll as
  select claimno,
         pac,
         sum(ntdincurredlossexclrevalusd) as ntdincurredlossexclrevalusd	
  from   (select * from claim where pac="GMMAM")
  group by claimno,
           pac
  having sum(ntdincurredlossexclrevalusd) &amp;gt; 50000;
run;&lt;/PRE&gt;
&lt;P&gt;Note that I put part of the having in a sub-query, I just find it simpler to see what data feeds into the larger grouping.&amp;nbsp; As we fix pac as only one where clause, pac could be totally removed from the outer loop without changing the outcome as it will always be GMMAM.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Nov 2018 12:57:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-TRANSLATION/m-p/510371#M1939</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-11-05T12:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: SQL TRANSLATION</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SQL-TRANSLATION/m-p/510460#M1962</link>
      <description>SAS Studio is SAS 9.4 TS1M5 and the code is the same regardless of which version of SAS you're using, at least for the code shown.</description>
      <pubDate>Mon, 05 Nov 2018 15:49:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SQL-TRANSLATION/m-p/510460#M1962</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-05T15:49:31Z</dc:date>
    </item>
  </channel>
</rss>

