<?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: Add subtotal for select rows in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Add-subtotal-for-select-rows/m-p/158954#M12367</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you want to use point and click or code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 27 Jun 2014 21:31:08 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2014-06-27T21:31:08Z</dc:date>
    <item>
      <title>Add subtotal for select rows</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Add-subtotal-for-select-rows/m-p/158953#M12366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example of my data structure:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;ProjectName&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;ExpenseType&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;AccountType&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Revenue&lt;/TD&gt;&lt;TD&gt;Revenue&lt;/TD&gt;&lt;TD&gt;1,200,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;One-Time Expense&lt;/TD&gt;&lt;TD&gt;Operations&lt;/TD&gt;&lt;TD&gt;10,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD colspan="1"&gt;A&lt;/TD&gt;&lt;TD colspan="1"&gt;One-Time Expense&lt;/TD&gt;&lt;TD colspan="1"&gt;Technnology&lt;/TD&gt;&lt;TD colspan="1"&gt;10,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Ongoing Expense&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Operations - Production&lt;/TD&gt;&lt;TD&gt;100,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Ongoing Expense&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Operations - NonProduction&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;50,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Ongoing Expense&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Operations - ProjectManagement&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;25,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Ongoing Expense&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Technology&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;500,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Ongoing Expense&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Depreciation&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;15,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Ongoing Expense&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Maintenance&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;75,000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to use the query builder in SAS EG to generate this resultant table.&amp;nbsp; The Ongoing Expense for Operations are summed together. Not sure if this is possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid #000000; width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;ProjectName&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;ExpenseType&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;AccountType&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;Amount&lt;/STRONG&gt;&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Revenue&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Revenue&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;1,200,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;One-Time Expense&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Operations&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;One Time Expense&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Technology&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;10,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Ongoing Expense&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Operations&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;175,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Ongoing Expense&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Technology&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;500,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;A&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Ongoing Expense&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;Depreciation&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;15,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Outgoing Expense&lt;/TD&gt;&lt;TD&gt;Maintenance&lt;/TD&gt;&lt;TD&gt;75,000&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;Total&lt;/TD&gt;&lt;TD&gt;Total&lt;/TD&gt;&lt;TD&gt;1,985,000&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All advice are greatly appreciated!&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 21:12:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Add-subtotal-for-select-rows/m-p/158953#M12366</guid>
      <dc:creator>jen123</dc:creator>
      <dc:date>2014-06-27T21:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: Add subtotal for select rows</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Add-subtotal-for-select-rows/m-p/158954#M12367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you want to use point and click or code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Jun 2014 21:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Add-subtotal-for-select-rows/m-p/158954#M12367</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-06-27T21:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Add subtotal for select rows</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Add-subtotal-for-select-rows/m-p/158955#M12368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would prefer point and click, but will take code.&amp;nbsp; I am a beginnner to coding but should be able to figure out the code.&lt;/P&gt;&lt;P&gt;Thanks Reeza!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jun 2014 00:21:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Add-subtotal-for-select-rows/m-p/158955#M12368</guid>
      <dc:creator>jen123</dc:creator>
      <dc:date>2014-06-28T00:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: Add subtotal for select rows</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Add-subtotal-for-select-rows/m-p/158956#M12369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For the record it seems weird to add revenue and expenses to a total. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try something like the following:&lt;/P&gt;&lt;P&gt;1. In Query Builder create a query that selects all columns and then create a computed column using the Advanced Calculation. The computed column will use the scan function to scan for a hyphen and take the first argument , scan(account_type, 1, "-") which will convert the Operations - XXXXX fields to Operations. &lt;/P&gt;&lt;P&gt;2. Use either a summary or summary table calculation to get the table required using the new computed column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or the code below may work (untested):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table want as&lt;/P&gt;&lt;P&gt;select * from &lt;/P&gt;&lt;P&gt;(select ProjectName, ExpenseType, scan(AccountType, 1, "-") as AccountType, sum(Amount) as Amount&lt;/P&gt;&lt;P&gt;from have&lt;/P&gt;&lt;P&gt;group by ProjectName, ExpenseType, calculated AccountType)&lt;/P&gt;&lt;P&gt;union&lt;/P&gt;&lt;P&gt;(&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;select ProjectName, 'Total' as ExpenseType,&amp;nbsp; 'Total' as AccountType, sum(Amount) as Amount&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;from have)&lt;/P&gt;&lt;P&gt;) as A;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jun 2014 18:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Add-subtotal-for-select-rows/m-p/158956#M12369</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-06-28T18:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Add subtotal for select rows</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Add-subtotal-for-select-rows/m-p/158957#M12370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza - Thanks for the feedback and I will give it a try.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FYI - I forgot to put the negative signs for expense.&amp;nbsp; Hence, that is why I am "adding" revenue and expenses.&amp;nbsp; With the negative, it's actually subtracting the expenses.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Jun 2014 19:24:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Add-subtotal-for-select-rows/m-p/158957#M12370</guid>
      <dc:creator>jen123</dc:creator>
      <dc:date>2014-06-28T19:24:13Z</dc:date>
    </item>
  </channel>
</rss>

