<?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 How to create total lines in Proc SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-total-lines-in-Proc-SQL/m-p/38026#M9701</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; &lt;EM&gt;union all&lt;/EM&gt; simply concatenates the tables. The second tables is the single Total line at the bottom.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;glad I could help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 22 Mar 2012 16:45:34 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2012-03-22T16:45:34Z</dc:date>
    <item>
      <title>How to create total lines in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-total-lines-in-Proc-SQL/m-p/38023#M9698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; So I have the following problem where I have this code, and I need to create total lines (not footnotes) at the bottom of my report to show the totals for Retail Price and quantity.&lt;/P&gt;&lt;P&gt; This is the code I have so far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select avg(Total_Retail_Price) into:Price&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from orion.order_fact&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where "&amp;amp;start"d&amp;lt;order_date&amp;lt;"&amp;amp;stop"d;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select avg(Quantity) format=comma4.2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; into:Quant&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from orion.order_fact&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where "&amp;amp;start"d&amp;lt;order_date&amp;lt;"&amp;amp;stop"d;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;title1 "Report from &amp;amp;start to &amp;amp;stop";&lt;/P&gt;&lt;P&gt;title3 "Average Quantity: &amp;amp;quant";&lt;/P&gt;&lt;P&gt;title4 "Average Price: &amp;amp;price";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select Order_ID, Order_Date, Quantity, Total_Retail_Price format=dollar5.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from orion.order_fact&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where "&amp;amp;start"d&amp;lt;order_date&amp;lt;"&amp;amp;stop"d;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I know in a proc print statement to get my total lines I need to just use sum and then whatever my variable is.&lt;/P&gt;&lt;P&gt;I am just not sure how to do something like that with a PROC SQL statement.&lt;/P&gt;&lt;P&gt;Could someone out there let me know how to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Alisa&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2012 19:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-create-total-lines-in-Proc-SQL/m-p/38023#M9698</guid>
      <dc:creator>InfoAlisaA</dc:creator>
      <dc:date>2012-03-20T19:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create total lines in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-total-lines-in-Proc-SQL/m-p/38024#M9699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select avg(Total_Retail_Price), avg(Quantity) format=comma4.2 &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; into :Price, :Quant&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from orion.order_fact&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where "&amp;amp;start"d &amp;lt; order_date &amp;lt; "&amp;amp;stop"d;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;title1 "Report from &amp;amp;start to &amp;amp;stop";&lt;/P&gt;&lt;P&gt;title3 "Average Quantity: &amp;amp;quant";&lt;/P&gt;&lt;P&gt;title4 "Average Price: &amp;amp;price";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; (select Order_ID, Order_Date, Quantity, Total_Retail_Price format=dollar5.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from orion.order_fact&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where "&amp;amp;start"d &amp;lt; order_date &amp;lt; "&amp;amp;stop"d)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; union all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; (select "Total", ., sum(Quantity), sum(Total_Retail_Price)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; from orion.order_fact&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where "&amp;amp;start"d &amp;lt; order_date &amp;lt; "&amp;amp;stop"d);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if Order_ID is numeric, then use put(Order_ID, best.) in the query.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Slight cosmetic modif by PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Mar 2012 20:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-create-total-lines-in-Proc-SQL/m-p/38024#M9699</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-03-20T20:15:42Z</dc:date>
    </item>
    <item>
      <title>How to create total lines in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-total-lines-in-Proc-SQL/m-p/38025#M9700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome! &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; This worked out perfectly. I did have to take out your parenthesis because SAS did not want to run the program with those in. How does the union all create total lines at the bottom of the file?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2012 16:40:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-create-total-lines-in-Proc-SQL/m-p/38025#M9700</guid>
      <dc:creator>InfoAlisaA</dc:creator>
      <dc:date>2012-03-22T16:40:46Z</dc:date>
    </item>
    <item>
      <title>How to create total lines in Proc SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-create-total-lines-in-Proc-SQL/m-p/38026#M9701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; &lt;EM&gt;union all&lt;/EM&gt; simply concatenates the tables. The second tables is the single Total line at the bottom.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;glad I could help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Mar 2012 16:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-create-total-lines-in-Proc-SQL/m-p/38026#M9701</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-03-22T16:45:34Z</dc:date>
    </item>
  </channel>
</rss>

