<?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 'group by' query in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by-query/m-p/577318#M163597</link>
    <description>&lt;P&gt;Your code is correct for producing summaries by ID.&lt;/P&gt;
&lt;P&gt;Personally, I prefer to use the column names instead of the position numbers, as this is robust against changes in the positional lineup of result columns, and easier to read and maintain.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jul 2019 11:03:14 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-07-29T11:03:14Z</dc:date>
    <item>
      <title>proc sql 'group by' query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by-query/m-p/577305#M163590</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please can someone explain the importance of the 'group by' statement when using proc sql and examples of how it should be used (i.e. when it should be 'group by 1,2,3;' etc. - is it the number of variables selected i.e. if five variables are selected, it would be 'group by 1,2,3,4,5;' and excludes any sum(variable) as [new variable name] when considering how many to group by? I have an example below of my code - can it be reviewed to see if it is correct and whether any changes need to be made? Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Code:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;proc sort data=test;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;by ID;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;create table consumer_balance as&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; select ID,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum(balance) as Total_balance,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count(*) as Volume&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; from test&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; group by 1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; ;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 08:59:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by-query/m-p/577305#M163590</guid>
      <dc:creator>jeremy4</dc:creator>
      <dc:date>2019-07-29T08:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 'group by' query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by-query/m-p/577318#M163597</link>
      <description>&lt;P&gt;Your code is correct for producing summaries by ID.&lt;/P&gt;
&lt;P&gt;Personally, I prefer to use the column names instead of the position numbers, as this is robust against changes in the positional lineup of result columns, and easier to read and maintain.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 11:03:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by-query/m-p/577318#M163597</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-29T11:03:14Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql 'group by' query</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by-query/m-p/577319#M163598</link>
      <description>&lt;P&gt;PS SQL does not need the extra sort, it does the necessary sorting on its own. Only under certain circumstances can the external sort help SQL in preventing bad performance or exceeding resource limits.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 11:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-group-by-query/m-p/577319#M163598</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-07-29T11:06:23Z</dc:date>
    </item>
  </channel>
</rss>

