<?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: PROC SQL - Sum over categorical variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Sum-over-categorical-variables/m-p/295391#M61719</link>
    <description>&lt;P&gt;Few quick rules that can help:&lt;/P&gt;
&lt;P&gt;*Grouping variables go in group by statement.&lt;/P&gt;
&lt;P&gt;*All other variables need to be an aggregate function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Items appearing in select are either from group by ( &amp;nbsp;not required) or an aggregation &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Aug 2016 05:27:59 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-08-31T05:27:59Z</dc:date>
    <item>
      <title>PROC SQL - Sum over categorical variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Sum-over-categorical-variables/m-p/295388#M61717</link>
      <description>&lt;P&gt;An interesting question:&lt;/P&gt;
&lt;P&gt;I've got table as follows where the variables are as follows:&lt;/P&gt;
&lt;P&gt;ID GROUP1 GROUP2 TYPE1 YEAR COUNT AMOUNT&lt;/P&gt;
&lt;P&gt;where ID is a primary key.&lt;/P&gt;
&lt;P&gt;I wish to create a table where the ID PK is dropped and where only the variables GROUP1 GROUP2 TYPE1 YEAR COUNT&lt;/P&gt;
&lt;P&gt;AMOUNT&amp;nbsp;appear but where &amp;nbsp;COUNT AMOUNT&amp;nbsp;consist of the sum over the categorical variables (GROUP1 GROUP2 TYPE1 YEAR).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, for every combination of the values of&amp;nbsp;each categorical variables, I have the sum of COUNT and the sum of AMOUNT.&lt;/P&gt;
&lt;P&gt;Any idea how to go about with this??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 05:25:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Sum-over-categorical-variables/m-p/295388#M61717</guid>
      <dc:creator>camfarrell25</dc:creator>
      <dc:date>2016-08-31T05:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SLQ - Sum over categorical variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Sum-over-categorical-variables/m-p/295389#M61718</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select  GROUP1 ,GROUP2 ,TYPE1, YEAR,
sum( COUNT), sum( AMOUNT)
from have
group by GROUP1 ,GROUP2 ,TYPE1, YEAR;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 Aug 2016 05:22:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Sum-over-categorical-variables/m-p/295389#M61718</guid>
      <dc:creator>RahulG</dc:creator>
      <dc:date>2016-08-31T05:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - Sum over categorical variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Sum-over-categorical-variables/m-p/295391#M61719</link>
      <description>&lt;P&gt;Few quick rules that can help:&lt;/P&gt;
&lt;P&gt;*Grouping variables go in group by statement.&lt;/P&gt;
&lt;P&gt;*All other variables need to be an aggregate function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Items appearing in select are either from group by ( &amp;nbsp;not required) or an aggregation &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 05:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Sum-over-categorical-variables/m-p/295391#M61719</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-31T05:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - Sum over categorical variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Sum-over-categorical-variables/m-p/295393#M61720</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Few quick rules that can help:&lt;/P&gt;
&lt;P&gt;*Grouping variables go in group by statement.&lt;/P&gt;
&lt;P&gt;*All other variables need to be an aggregate function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*Items appearing in select are either from group by ( &amp;nbsp;not required) or an aggregation &amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There's exceptions to these rules in SAS SQL but working from this will help you avoid issues.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2016 06:13:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Sum-over-categorical-variables/m-p/295393#M61720</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-08-31T06:13:31Z</dc:date>
    </item>
  </channel>
</rss>

