<?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: Why we need both select and group by in proc sql? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-we-need-both-select-and-group-by-in-proc-sql/m-p/729610#M227087</link>
    <description>&lt;P&gt;I think we should learn SQL first, not SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SELECT:&lt;BR /&gt;&lt;A href="https://www.w3schools.com/sql/sql_select.asp" target="_blank"&gt;https://www.w3schools.com/sql/sql_select.asp&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you write the following code without gender, you will see the difference.&lt;BR /&gt;You will not be able to tell what the counted number corresponds to.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select count(distinct(name)) as no_of_name
   from sashelp.class
group by sex;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-03-28_15h21_17.png" style="width: 192px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56577iC72D27C5240B2070/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-03-28_15h21_17.png" alt="2021-03-28_15h21_17.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 28 Mar 2021 06:22:57 GMT</pubDate>
    <dc:creator>japelin</dc:creator>
    <dc:date>2021-03-28T06:22:57Z</dc:date>
    <item>
      <title>Why we need both select and group by in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-we-need-both-select-and-group-by-in-proc-sql/m-p/729606#M227084</link>
      <description>&lt;P&gt;Hi all SAS Users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Today I played around with the sashelp.class and I wrote a code as below to count the distinct name of students in each gender, and the code run flawlessly.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select &lt;STRONG&gt;sex&lt;/STRONG&gt;
   ,count(distinct(&lt;STRONG&gt;name&lt;/STRONG&gt;)) as no_of_name
   from &lt;STRONG&gt;sashelp.class&lt;/STRONG&gt;
group by &lt;STRONG&gt;sex&lt;/STRONG&gt;;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Even I wrote the code, but I am not sure why we need both &lt;STRONG&gt;select&lt;/STRONG&gt; and &lt;STRONG&gt;group by&lt;/STRONG&gt; within this data step? I can understand that we need group by to announce the compiler that we want to deal with the &lt;STRONG&gt;name&lt;/STRONG&gt; in each&lt;STRONG&gt; sex&lt;/STRONG&gt; category but what &lt;STRONG&gt;select&lt;/STRONG&gt; for?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warmest regards.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Mar 2021 05:12:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-we-need-both-select-and-group-by-in-proc-sql/m-p/729606#M227084</guid>
      <dc:creator>Phil_NZ</dc:creator>
      <dc:date>2021-03-28T05:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: Why we need both select and group by in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-we-need-both-select-and-group-by-in-proc-sql/m-p/729607#M227085</link>
      <description>&lt;P&gt;First of all, this is not a DATA step, this is a PROC SQL step.&lt;/P&gt;
&lt;P&gt;And the SQL statement that starts a query is SELECT. It is basic SQL syntax.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Mar 2021 05:35:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-we-need-both-select-and-group-by-in-proc-sql/m-p/729607#M227085</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-28T05:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why we need both select and group by in proc sql?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-we-need-both-select-and-group-by-in-proc-sql/m-p/729610#M227087</link>
      <description>&lt;P&gt;I think we should learn SQL first, not SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SELECT:&lt;BR /&gt;&lt;A href="https://www.w3schools.com/sql/sql_select.asp" target="_blank"&gt;https://www.w3schools.com/sql/sql_select.asp&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you write the following code without gender, you will see the difference.&lt;BR /&gt;You will not be able to tell what the counted number corresponds to.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select count(distinct(name)) as no_of_name
   from sashelp.class
group by sex;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2021-03-28_15h21_17.png" style="width: 192px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/56577iC72D27C5240B2070/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-03-28_15h21_17.png" alt="2021-03-28_15h21_17.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Mar 2021 06:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-we-need-both-select-and-group-by-in-proc-sql/m-p/729610#M227087</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2021-03-28T06:22:57Z</dc:date>
    </item>
  </channel>
</rss>

