<?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: Sum and mean combined in SAS VA in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Sum-and-mean-combined-in-SAS-VA/m-p/769079#M15309</link>
    <description>&lt;P&gt;I don't understand what this aggregation scheme should accomplish, for me it's confusing to mix average and sum in combination with hierarchies.&lt;/P&gt;
&lt;P&gt;nevertheless I think it can be done with the aggregated measure by building a nested container.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data public.test_com(promote=yes);
infile datalines;
format date $9.;
input Week  Date $    Department $ Sub_department $ Value;
datalines;
1          01jan2021  A                   A1                       8
1          02jan2021  A                   A1                       9
1          03jan2021  A                   A1                      10
1          01jan2021  A                   A2                       2
1          02jan2021  A                   A2                       1
1          03jan2021  A                   A2                       0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cross tabs.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63868i1C671FBF177B82AC/image-size/large?v=v2&amp;amp;px=999" role="button" title="cross tabs.png" alt="cross tabs.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aggr.png" style="width: 818px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63869iD1970D2A14D9194F/image-size/large?v=v2&amp;amp;px=999" role="button" title="aggr.png" alt="aggr.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Sep 2021 09:35:45 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2021-09-22T09:35:45Z</dc:date>
    <item>
      <title>Sum and mean combined in SAS VA</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Sum-and-mean-combined-in-SAS-VA/m-p/769016#M15308</link>
      <description>&lt;P&gt;Hi all I have data that in two different hierarchies.&lt;/P&gt;&lt;P&gt;Week-date and department sub department.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example data looks like this&lt;/P&gt;&lt;P&gt;Week&amp;nbsp; Date&amp;nbsp; &amp;nbsp; Department Sub-department Value&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01jan&amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;8&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02jan&amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03jan&amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 01jan&amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 02jan&amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 03jan&amp;nbsp; A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;A2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to have a cross table that has the week date as rows , department sub-department as columns.&lt;/P&gt;&lt;P&gt;I want the average by week date and the sum of department sub-department&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want for collapsed hiearchies&lt;/P&gt;&lt;P&gt;Week&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Department&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;10&lt;/P&gt;&lt;P&gt;What I get using mean for value&amp;nbsp;&lt;/P&gt;&lt;P&gt;Week&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Department&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;/P&gt;&lt;P&gt;What I get using sum for value&amp;nbsp;&lt;/P&gt;&lt;P&gt;Week&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Department&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;30&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When expanding department to sub-department I get the right mean when week-date is collapsed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried several different combination of sum and mean, calculating the number of days and trying table aggregations.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can solve this by creating an aggregation by week date- department and create a cross tab on this. Then I need to create two crosstabs, one for collapsed department and on for expanded department.&lt;/P&gt;&lt;P&gt;This is not really elegant. In the real use case I already have several aggregation and joins and really want to avoid to many.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I seem to remember that I had the same challenge in Proc Tabulate back in the late 90's and managed to solve this by a strange combination of crossings.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there anybody who has been able to solve this problem without using a separate aggregated table?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2021 06:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Sum-and-mean-combined-in-SAS-VA/m-p/769016#M15308</guid>
      <dc:creator>PaalNavestad</dc:creator>
      <dc:date>2021-09-22T06:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Sum and mean combined in SAS VA</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Sum-and-mean-combined-in-SAS-VA/m-p/769079#M15309</link>
      <description>&lt;P&gt;I don't understand what this aggregation scheme should accomplish, for me it's confusing to mix average and sum in combination with hierarchies.&lt;/P&gt;
&lt;P&gt;nevertheless I think it can be done with the aggregated measure by building a nested container.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data public.test_com(promote=yes);
infile datalines;
format date $9.;
input Week  Date $    Department $ Sub_department $ Value;
datalines;
1          01jan2021  A                   A1                       8
1          02jan2021  A                   A1                       9
1          03jan2021  A                   A1                      10
1          01jan2021  A                   A2                       2
1          02jan2021  A                   A2                       1
1          03jan2021  A                   A2                       0
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="cross tabs.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63868i1C671FBF177B82AC/image-size/large?v=v2&amp;amp;px=999" role="button" title="cross tabs.png" alt="cross tabs.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="aggr.png" style="width: 818px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63869iD1970D2A14D9194F/image-size/large?v=v2&amp;amp;px=999" role="button" title="aggr.png" alt="aggr.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2021 09:35:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Sum-and-mean-combined-in-SAS-VA/m-p/769079#M15309</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2021-09-22T09:35:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sum and mean combined in SAS VA</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/Sum-and-mean-combined-in-SAS-VA/m-p/769153#M15316</link>
      <description>&lt;P&gt;Thanks a lot. Yes it is confusing mixing sum and mean. However the data is daily averages so you want an average by date and a sum of the departments. This creates a lot of havoc in a lot of reporting and analysis. Most of the use cases is by day or by month. Then you can use sum of month and calculate daily by dividing by days in month. However this do not work in this case as the data is updated daily and you will never know if you have complete months.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Sep 2021 13:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/Sum-and-mean-combined-in-SAS-VA/m-p/769153#M15316</guid>
      <dc:creator>PaalNavestad</dc:creator>
      <dc:date>2021-09-22T13:11:22Z</dc:date>
    </item>
  </channel>
</rss>

