<?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: obtaining a summary row after individual rows in sql in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/obtaining-a-summary-row-after-individual-rows-in-sql/m-p/413831#M101321</link>
    <description>&lt;P&gt;Do your records overlap within X/ by group?&lt;/P&gt;
&lt;P&gt;ie If you sum the total from the summary total are you expecting it to add to the total, or do you need a separate distinct count because of the overlap?&lt;/P&gt;
&lt;P&gt;If you need that distinction I can't think of an alternative &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully someone else can, so partially responding to see if there is a solution to this problem.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Nov 2017 22:29:33 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-11-15T22:29:33Z</dc:date>
    <item>
      <title>obtaining a summary row after individual rows in sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/obtaining-a-summary-row-after-individual-rows-in-sql/m-p/413818#M101315</link>
      <description>&lt;P&gt;The code below creates a unique count of the variable y for each value of x and a summary row.&amp;nbsp;&amp;nbsp; However, it requires two queries and a data step.&amp;nbsp;&amp;nbsp; Is there a way to all in one query?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*sample data*/&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; x &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;$1.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; y &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;a1&lt;/P&gt;&lt;P&gt;a2&lt;/P&gt;&lt;P&gt;a2&lt;/P&gt;&lt;P&gt;b1&lt;/P&gt;&lt;P&gt;b3&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*first query*/&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; x, n(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;distinct&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; y) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; y_cnt&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;group&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; x;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*second query*/&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;create&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;table&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; c &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt; &lt;FONT color="#800080" face="Courier New" size="3"&gt;'Total'&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; x, n(&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;distinct&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; y) &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;as&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; y_cnt&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; a;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; d;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; x $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="3"&gt;/*append queries*/&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; b c;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 21:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/obtaining-a-summary-row-after-individual-rows-in-sql/m-p/413818#M101315</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2017-11-15T21:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: obtaining a summary row after individual rows in sql</title>
      <link>https://communities.sas.com/t5/SAS-Programming/obtaining-a-summary-row-after-individual-rows-in-sql/m-p/413831#M101321</link>
      <description>&lt;P&gt;Do your records overlap within X/ by group?&lt;/P&gt;
&lt;P&gt;ie If you sum the total from the summary total are you expecting it to add to the total, or do you need a separate distinct count because of the overlap?&lt;/P&gt;
&lt;P&gt;If you need that distinction I can't think of an alternative &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully someone else can, so partially responding to see if there is a solution to this problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Nov 2017 22:29:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/obtaining-a-summary-row-after-individual-rows-in-sql/m-p/413831#M101321</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-15T22:29:33Z</dc:date>
    </item>
  </channel>
</rss>

