<?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: Data Remerging in PROC SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Data-Remerging-in-PROC-SQL/m-p/206818#M51384</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where does the first example fall under?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Jul 2015 20:27:53 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-07-20T20:27:53Z</dc:date>
    <item>
      <title>Data Remerging in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-Remerging-in-PROC-SQL/m-p/206815#M51381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Folks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px; background-color: #ffffff;"&gt;&amp;nbsp; I have a quick question on&amp;nbsp; &lt;STRONG&gt; Data Remerging&amp;nbsp; &lt;/STRONG&gt; in&lt;STRONG&gt; PROC SQL.&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px; background-color: #ffffff;"&gt;I was going through the Book &lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px;"&gt;&lt;STRONG&gt; SAS Certification Prep Guide: Advanced Programming for SAS 9, Fourth Edition&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; and&amp;nbsp; in&amp;nbsp;&amp;nbsp; Chapter 2 (&lt;STRONG&gt;Performing Advanced Queries with PROC SQL)&lt;/STRONG&gt;&amp;nbsp; under the topic &lt;STRONG&gt;Understanding Data Remerging&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px; background-color: #ffffff;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px; background-color: #ffffff;"&gt;The book says one of the condition under which Data Remerging will occur in PROC SQL is the following :&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="color: #222222; font-family: arial, sans-serif; font-size: 12.8000001907349px; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;DIV&gt;&lt;EM&gt;The &lt;STRONG&gt;HAVING&lt;/STRONG&gt; clause specifies &lt;STRONG&gt;one or more columns or column expressions&lt;/STRONG&gt; that are &lt;STRONG&gt;not included in a subquery&lt;/STRONG&gt; or a GROUP BY clause.&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;The same Condition is also provided here under the section : &lt;SPAN style="color: #000000; font-family: arial, 'Arial Unicode MS', geneva, 'Lucida Grande', sans-serif; font-size: 10pt; font-weight: bold; line-height: 1.5em; background-color: #ffffff;"&gt;Remerging Summary Statistics&lt;/SPAN&gt;&lt;BR /&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm#p0xwc73ekemkapn1byhceqrwrisb.htm" title="http://support.sas.com/documentation/cdl/en/sqlproc/63043/HTML/default/viewer.htm#p0xwc73ekemkapn1byhceqrwrisb.htm"&gt;SAS(R) 9.3 SQL Procedure User's Guide&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to understand the above&amp;nbsp; condition.&amp;nbsp; I understand the Data remerging&amp;nbsp; when the HAVING Clause has a Column/Expression which is not in the&amp;nbsp; GROUP BY&amp;nbsp; Clause&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For eg&amp;nbsp; , the below PROC SQL will show Data Remerging because the HAVING Clause has a column &lt;STRONG&gt;Salary&lt;/STRONG&gt; which is NOT in the GROUP BY Clause&amp;nbsp; assuming the dataset&amp;nbsp; &lt;SPAN style="font-size: 13.3333330154419px;"&gt;sasuser.payrollmaster&amp;nbsp; has columns&amp;nbsp; JobCode&amp;nbsp; and Salary&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;proc sql;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select jobcode, avg( salary) as AvgSalary format = dollar11.2&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from sasuser.payrollmaster&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; group by JobCode&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; having &lt;STRONG&gt;salary&lt;/STRONG&gt; &amp;gt; avg( salary);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But unable to understand how&amp;nbsp; the Data remerging occurs when the Column/Expression is &lt;STRONG&gt;not present in a Subquery&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Can someone&amp;nbsp; help me with a PROC SQL&amp;nbsp; example which shows Data remerging occuring if the HAVING clause has a Column/Expression which is NOT present in a Sub query.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Prashant&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 18:34:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-Remerging-in-PROC-SQL/m-p/206815#M51381</guid>
      <dc:creator>pchegoor</dc:creator>
      <dc:date>2015-07-20T18:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Data Remerging in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-Remerging-in-PROC-SQL/m-p/206816#M51382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although I think this illustrates the issue, in practice it usually occurs when the variable is in the SELECT statement and not summarized or used in a HAVING/GROUP BY that you'll get the remerge warning. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;title 'Remerging example';&lt;/P&gt;&lt;P&gt;select sex,&amp;nbsp; mean(weight) as weight&lt;/P&gt;&lt;P&gt;from sashelp.class&lt;/P&gt;&lt;P&gt;group by sex&lt;/P&gt;&lt;P&gt;having age&amp;gt;12;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title 'Values from original data, no HAVE clause';&lt;/P&gt;&lt;P&gt;select sex, age, mean(weight) as weight&lt;/P&gt;&lt;P&gt;from sashelp.class&lt;/P&gt;&lt;P&gt;group by sex;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;title 'Not equivalent to WHERE';&lt;/P&gt;&lt;P&gt;select sex, age, mean(weight) as weight&lt;/P&gt;&lt;P&gt;from sashelp.class&lt;/P&gt;&lt;P&gt;where age&amp;gt;12&lt;/P&gt;&lt;P&gt;group by sex;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 19:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-Remerging-in-PROC-SQL/m-p/206816#M51382</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-07-20T19:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Data Remerging in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-Remerging-in-PROC-SQL/m-p/206817#M51383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Reeza.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;According to the Advanced SAS&amp;nbsp; Prep Guide&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;Data&amp;nbsp; Remerging&lt;/STRONG&gt; occurs&amp;nbsp; in PROC SQL whenever any of the following conditions exist:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The values returned by a summary function are used in a calculation. &lt;/LI&gt;&lt;LI&gt;The SELECT clause specifies a column that contains a summary function and other column( s) that are not listed in a GROUP BY clause.&lt;/LI&gt;&lt;LI&gt;The HAVING clause specifies one or more columns or column expressions that are not included in a subquery or a GROUP BY clause.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; The Examples you&amp;nbsp; provided do not involve any Sub queries&amp;nbsp; but&amp;nbsp; includes&amp;nbsp; Scenario&amp;nbsp; 2 above&amp;nbsp; 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a scenario where the Subquery in HAVING Clause causes Data Remerging&amp;nbsp; as mentioned by scenario 3 above?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 20:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-Remerging-in-PROC-SQL/m-p/206817#M51383</guid>
      <dc:creator>pchegoor</dc:creator>
      <dc:date>2015-07-20T20:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Data Remerging in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-Remerging-in-PROC-SQL/m-p/206818#M51384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where does the first example fall under?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 20:27:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-Remerging-in-PROC-SQL/m-p/206818#M51384</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-07-20T20:27:53Z</dc:date>
    </item>
    <item>
      <title>Re: Data Remerging in PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Data-Remerging-in-PROC-SQL/m-p/206819#M51385</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Reeza,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Your First Example falls under Scenario&amp;nbsp; 3&amp;nbsp; above where the HAVING Clause has a Column or Expression not in the GROUP BY Clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was looking for a&amp;nbsp; PROC SQL&amp;nbsp; Example which involves a Sub query&amp;nbsp; and HAVING Clause&amp;nbsp; in Scenario 3&amp;nbsp; which causes&amp;nbsp; Data Remerging.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 20:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Data-Remerging-in-PROC-SQL/m-p/206819#M51385</guid>
      <dc:creator>pchegoor</dc:creator>
      <dc:date>2015-07-20T20:52:12Z</dc:date>
    </item>
  </channel>
</rss>

