<?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: Group by user - total and average in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Group-by-user-total-and-average/m-p/822534#M324814</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have;
    class region name dcode;
    types region*name region*name*dcode;
    var travel;
    output out=want sum=tot_travel mean=avg_travel;
run;
    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;From there, sorting the data will get you the layout you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=want;
    by region name descending _type_ dcode;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 11 Jul 2022 12:41:33 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-07-11T12:41:33Z</dc:date>
    <item>
      <title>Group by user - total and average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-user-total-and-average/m-p/822528#M324810</link>
      <description>&lt;P&gt;Hi, Could someone help me with below :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input REGION $ NAME $ DATE :datetime20. DCODE $ TRAVEL;
format date datetime20.;
datalines;
EAST	LEE		01JUN2022:00:00:00	AP64389	21.09
EAST	LEE		03JUN2022:00:00:00	AP64389	15.19
EAST	SAM		05JUN2022:00:00:00	PS1234	4.14
EAST	LEE		07JUN2022:00:00:00	GP38299	2.09
WEST	DAN		07JUN2022:00:00:00	CX78934	10.07
WEST	DAN		07JUN2022:00:00:00	CX78934	8.07
WEST	DAN		07JUN2022:00:00:00	PB53468	10.07
WEST	DAN		07JUN2022:00:00:00	PB53468	10.07
SOUTH	TIM		02JUN2022:00:00:00	SU18934	52.23
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Expected output :&lt;/P&gt;
&lt;P&gt;I need to show the total count of codes based on the user level, from above NAME LEE has to AP64389 repeated two times so the count will be 2. and the tot_travel is total of AP64389 (21.09+15.19 = 36.28) and the avg_travel will be (36.28/2 = 18.14)&lt;/P&gt;
&lt;P&gt;and the bottom of each name i need to show the total of count, tot_travel, and the avg_travel should be total of tot_travel/total of count i.e., 38.37/3 = 12.79&lt;/P&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="vnreddy_0-1657539346354.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73126iDC8C613D4738D3CB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="vnreddy_0-1657539346354.png" alt="vnreddy_0-1657539346354.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I need the report in same format, could someone help me how can i achive this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 12:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-user-total-and-average/m-p/822528#M324810</guid>
      <dc:creator>vnreddy</dc:creator>
      <dc:date>2022-07-11T12:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Group by user - total and average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-user-total-and-average/m-p/822532#M324813</link>
      <description>&lt;P&gt;Why is Lee with Dcode = PS1234 ignored?&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 11:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-user-total-and-average/m-p/822532#M324813</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-07-11T11:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Group by user - total and average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-user-total-and-average/m-p/822534#M324814</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have;
    class region name dcode;
    types region*name region*name*dcode;
    var travel;
    output out=want sum=tot_travel mean=avg_travel;
run;
    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;From there, sorting the data will get you the layout you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=want;
    by region name descending _type_ dcode;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Jul 2022 12:41:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-user-total-and-average/m-p/822534#M324814</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-11T12:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: Group by user - total and average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-user-total-and-average/m-p/822535#M324815</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;sorry it's my bad, updated now.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 12:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-user-total-and-average/m-p/822535#M324815</guid>
      <dc:creator>vnreddy</dc:creator>
      <dc:date>2022-07-11T12:01:12Z</dc:date>
    </item>
    <item>
      <title>Re: Group by user - total and average</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Group-by-user-total-and-average/m-p/822540#M324817</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
input REGION $ NAME $ DATE :datetime20. DCODE $ TRAVEL;
format date datetime20.;
datalines;
EAST	LEE		01JUN2022:00:00:00	AP64389	21.09
EAST	LEE		03JUN2022:00:00:00	AP64389	15.19
EAST	SAM		05JUN2022:00:00:00	PS1234	4.14
EAST	LEE		07JUN2022:00:00:00	GP38299	2.09
WEST	DAN		07JUN2022:00:00:00	CX78934	10.07
WEST	DAN		07JUN2022:00:00:00	CX78934	8.07
WEST	DAN		07JUN2022:00:00:00	PB53468	10.07
WEST	DAN		07JUN2022:00:00:00	PB53468	10.07
SOUTH	TIM		02JUN2022:00:00:00	SU18934	52.23
;
run;
proc report data=want nowd;
column  REGION  NAME DCODE n TRAVEL TRAVEL=TRAVEL1;
define REGION/group order=data;
define NAME/group;
define DCODE/group;
define n/'COUNT';
define TRAVEL/analysis sum 'TOT_TRAVEL';
define TRAVEL1/analysis mean 'AVG_TRAVEL';
compute after NAME;
REGION=' ';
endcomp;
break after NAME/summarize;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1657543142292.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73129iFAD9E5376655E2E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1657543142292.png" alt="Ksharp_0-1657543142292.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jul 2022 12:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Group-by-user-total-and-average/m-p/822540#M324817</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-07-11T12:39:09Z</dc:date>
    </item>
  </channel>
</rss>

