<?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 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801258#M315331</link>
    <description>&lt;P&gt;Normally, I would say "try it", but this code won't run anyway because of syntax ERRORs. So fix those, then run it and see what the addition of the keyword BY changes (or does not change).&lt;/P&gt;
&lt;P&gt;Then decide how you want consistency in your codes with regards to being "terse" or "wordy".&lt;/P&gt;</description>
    <pubDate>Thu, 10 Mar 2022 08:00:53 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-03-10T08:00:53Z</dc:date>
    <item>
      <title>group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801254#M315328</link>
      <description>&lt;PRE&gt;proc sql;
create table real as select 
apple
orange
std(abc) as real_std_abc,
count(*) as real_cnt_abc
AVG(abc) as REAL_abc
from real
group apple, orange;&lt;/PRE&gt;
&lt;P&gt;I am studying this code and I wonder if the last line group apple, orange same as group by apple, orange?&lt;/P&gt;
&lt;P&gt;as I dont know what gorup apple, orange would here otherwise...&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 07:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801254#M315328</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-10T07:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801258#M315331</link>
      <description>&lt;P&gt;Normally, I would say "try it", but this code won't run anyway because of syntax ERRORs. So fix those, then run it and see what the addition of the keyword BY changes (or does not change).&lt;/P&gt;
&lt;P&gt;Then decide how you want consistency in your codes with regards to being "terse" or "wordy".&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 08:00:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801258#M315331</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-10T08:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801261#M315333</link>
      <description>&lt;PRE&gt;data lemon;
  input up down abc;
datalines;
2 5 6
3 2 7
3 2 7
2 5 6
19 33 363
run;



proc sql;
create table real as select 
up,
down,
std(abc) as real_std_abc,
count(*) as real_cnt_abc,
AVG(abc) as REAL_abc
from lemon
group by up;
quit;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;/PRE&gt;
&lt;P&gt;I tried different scenario using group , or group by just keep getting same results. I still dont know what group means when it is used on its own without by... please help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HeatherNewton_0-1646901515248.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69313iF8A37A496B873384/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HeatherNewton_0-1646901515248.png" alt="HeatherNewton_0-1646901515248.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 08:38:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801261#M315333</guid>
      <dc:creator>HeatherNewton</dc:creator>
      <dc:date>2022-03-10T08:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801262#M315334</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/416388"&gt;@HeatherNewton&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At first sight I would say "the group without by will give you&amp;nbsp; an error", but in case of Proc SQL it seems to be not the case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following test shows that Proc SQL seems to run ok wit both "group" and "group by" (in contrary to Proc FedSQL which throws an error).&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1    data work.class;
2      set sashelp.class;
3    run;

NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.CLASS has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


4
5    proc sql;
6      select sex, sum(age)
7      from work.class
8      group by sex
9      ;
10   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


11
12   proc sql;
13     select sex, sum(age)
14     from work.class
15     group sex
16     ;
17   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


18
19   proc fedsql;
20     select sex, sum(age)
21     from work.class
22     group by sex
23     ;
24   quit;

NOTE: PROCEDURE FEDSQL used (Total process time):
      real time           0.09 seconds
      cpu time            0.10 seconds


25
26   proc fedsql;
27     select sex, sum(age)
28     from work.class
29     group sex
30     ;
ERROR: Syntax error at or near "SEX"
31   quit;

NOTE: PROCEDURE FEDSQL used (Total process time):
      real time           0.05 seconds
      cpu time            0.04 seconds
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess it may be an "undocumented feature" of Proc SQL, but if I were you I would use "group by" just for clarity of the syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 09:03:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801262#M315334</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2022-03-10T09:03:08Z</dc:date>
    </item>
    <item>
      <title>Re: group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801269#M315337</link>
      <description>&lt;P&gt;SAS PROC SQL simply tolerates the omission of the BY, but I (and probably many others) consider this bad practice.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 09:48:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801269#M315337</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-03-10T09:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: group by</title>
      <link>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801371#M315384</link>
      <description>&lt;P&gt;I don't know where you are getting code like this to study but whatever source you have is a &lt;STRONG&gt;very bad source.&lt;/STRONG&gt; If that is actually what the source has, then there are multiple errors related to not separating values on the Select clause (requires a comma between each variable / expression creating a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS will assume the "by" when just Group is used.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2022 16:03:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/group-by/m-p/801371#M315384</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-10T16:03:54Z</dc:date>
    </item>
  </channel>
</rss>

