<?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: what's wrong with this proc sql in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/what-s-wrong-with-this-proc-sql/m-p/847496#M36954</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;i try to group them by id, year and area and i used the following code:&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;The data is already grouped by id, area and year, but you want id, year and area? Is that it? This is simply a sort of the data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
    by id year area;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 02 Dec 2022 19:42:40 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-12-02T19:42:40Z</dc:date>
    <item>
      <title>what's wrong with this proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/what-s-wrong-with-this-proc-sql/m-p/847492#M36952</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i am new to the proc sql in sas. my dataset like this:&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set DATA.CLIENTEMATGA2" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col" width="57px"&gt;Obs&lt;/TH&gt;
&lt;TH class="l header" scope="col" width="40px"&gt;id&lt;/TH&gt;
&lt;TH class="l header" scope="col" width="98px"&gt;area&lt;/TH&gt;
&lt;TH class="r header" scope="col" width="47px"&gt;year&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row" width="57px"&gt;5818&lt;/TH&gt;
&lt;TD width="40px" class="l data"&gt;1&lt;/TD&gt;
&lt;TD width="98px" class="l data"&gt;NEW YORK&lt;/TD&gt;
&lt;TD width="47px" class="r data"&gt;2020&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row" width="57px"&gt;5819&lt;/TH&gt;
&lt;TD width="40px" class="l data"&gt;1&lt;/TD&gt;
&lt;TD width="98px" class="l data"&gt;NEW YORK&lt;/TD&gt;
&lt;TD width="47px" class="r data"&gt;2021&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row" width="57px"&gt;5820&lt;/TH&gt;
&lt;TD width="40px" class="l data"&gt;1&lt;/TD&gt;
&lt;TD width="98px" class="l data"&gt;NEWARK&lt;/TD&gt;
&lt;TD width="47px" class="r data"&gt;2020&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row" width="57px"&gt;5821&lt;/TH&gt;
&lt;TD width="40px" class="l data"&gt;1&lt;/TD&gt;
&lt;TD width="98px" class="l data"&gt;NEWARK&lt;/TD&gt;
&lt;TD width="47px" class="r data"&gt;2021&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;i try to group them by id, year and area and i used the following code:&lt;/P&gt;
&lt;P&gt;i think i supposed to get only two records but instead, i still got the 4 records. i can't figure out what's wrong with this code.&amp;nbsp;&lt;BR /&gt;proc sql;&lt;BR /&gt;create table data.clientematga2&lt;BR /&gt;as select distinct a.id, a.area, a.year&lt;BR /&gt;from data.clientematga a&lt;BR /&gt;group by euci42, ematga , a.year;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 02 Dec 2022 19:32:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/what-s-wrong-with-this-proc-sql/m-p/847492#M36952</guid>
      <dc:creator>juliajulia</dc:creator>
      <dc:date>2022-12-02T19:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/what-s-wrong-with-this-proc-sql/m-p/847494#M36953</link>
      <description>&lt;P&gt;What does your log say?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hard to say without seeing representative data. You have columns in your group by clause that do not appear in your posted data.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2022 19:38:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/what-s-wrong-with-this-proc-sql/m-p/847494#M36953</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-12-02T19:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/what-s-wrong-with-this-proc-sql/m-p/847496#M36954</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;i try to group them by id, year and area and i used the following code:&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;The data is already grouped by id, area and year, but you want id, year and area? Is that it? This is simply a sort of the data&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have;
    by id year area;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Dec 2022 19:42:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/what-s-wrong-with-this-proc-sql/m-p/847496#M36954</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-12-02T19:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/what-s-wrong-with-this-proc-sql/m-p/847497#M36955</link>
      <description>&lt;P&gt;Good evening!&lt;BR /&gt;The "select distinct" refers to uniqueness in all columns given as an argument, in your case id, year, area ... &lt;BR /&gt;Now as I see four different (distinct) combinations in the sample provided by you, why do you expect 2 rows?&lt;BR /&gt;--fja&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2022 20:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/what-s-wrong-with-this-proc-sql/m-p/847497#M36955</guid>
      <dc:creator>fja</dc:creator>
      <dc:date>2022-12-02T20:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: what's wrong with this proc sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/what-s-wrong-with-this-proc-sql/m-p/847499#M36957</link>
      <description>&lt;PRE&gt;group by &lt;FONT color="#FF0000"&gt;euci42, ematga&lt;/FONT&gt; , a.year&lt;/PRE&gt;
&lt;P&gt;What is contained in these variables? Why do you use GROUP BY without a summary function (SAS SQL will automatically convert this to ORDER BY)? Why do you use variables in the GROUP BY which are not contained in your SELECT?&lt;/P&gt;
&lt;P&gt;GROUP BY is used to calculate summary statistics for the groups, not for simple re-ordering.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post usable example data in a data step with datalines, and the expected result.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2022 20:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/what-s-wrong-with-this-proc-sql/m-p/847499#M36957</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-12-02T20:05:48Z</dc:date>
    </item>
  </channel>
</rss>

