<?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 Calculating Avg at column level for total of Avg's in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Avg-at-column-level-for-total-of-Avg-s/m-p/811861#M320268</link>
    <description>&lt;P&gt;Hello - I created a table and proc report, code below and image of table.&amp;nbsp; &amp;nbsp;I calculated "AVG APPS RTS" by dividing "Total Contracted&amp;nbsp; / Ready To Sell" at the row level. how do I get the&amp;nbsp;"AVG APPS RTS" at the column level so that in the total bar at the bottom of my table&amp;nbsp; it shows the&amp;nbsp;"AVG APPS RTS" instead as a sum of the rows?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; create table TOHFinal as
Select Distinct
a.AGENCYNAME,
b.AHIPNeeded format=comma10., 
c.ReadyToTrain format=comma10.,
d.ReadyToSell format=comma10.,
sum(b.AHIPNeeded,c.ReadyToTrain,d.ReadyToSell) as TotalContracted format=comma10.,
0 as '2022 Sales Goal'n,
a.'2022 Sales'n format=comma10.,
calculated TotalContracted/d.ReadyToSell as Avg_Apps_RTS format=comma10.2,
today() as Rundate Format=MMDDYYS10.
From Active_Count2 a
left join Count_AHIPNeeded_TOH b 
on a.TOH_AGENCY=b.TOH_AGENCY
left join Count_ReadyToTrain_TOH c 
on a.TOH_AGENCY=c.TOH_AGENCY
left join Count_ReadyToSell_TOH d 
on a.TOH_AGENCY=d.TOH_AGENCY
Where a.AGENCYNAME is not Null 
;
quit;

proc report data=TOHFinal  nowd split='|' spanrows
style(header) = [font=("Arial",10.0pt) vjust=middle just=center background=%RGB(0,145,204) foreground=whitesmoke font_weight=bold];
   cols AGENCYNAME AHIPNEEDED READYTOTRAIN READYTOSELL TOTALCONTRACTED '2022 SALES GOAL'n '2022 SALES'n AVG_APPS_RTS;

	define AGENCYNAME / "AGENCY NAME" order=data ;
	define AHIPNEEDED / "AHIP NEEDED" style(column)={vjust=c just=c cellwidth = 1in} order=data;
	define READYTOTRAIN / "READY | TO TRAIN" style(column)={vjust=c just=c cellwidth = 1in};
	define READYTOSELL / "READY | TO SELL" style(column)={vjust=c just=c cellwidth = 1in};
	define TOTALCONTRACTED / "TOTAL CONTRACTED" style(column)={vjust=c just=c cellwidth = 1in} order=data ;
	define '2022 SALES GOAL'n / "2022 SALES GOAL" style(column)={vjust=c just=c cellwidth = 1in} order=data;
	define '2022 SALES'n / "2022 | SALES" style(column)={vjust=c just=c cellwidth = 1in};
	define AVG_APPS_RTS / "AVG | APPS RTS" style(column)={vjust=c just=c cellwidth = 1in};           
	rbreak after /summarize  style=[fontweight=bold];
	compute before _page_/style=[font=("Arial",12.5pt) vjust=middle just=center background=whitesmoke foreground=%RGB(0,145,204) font_weight=bold borderbottomcolor=%RGB(242,242,242)];
	 line "WEEKLY TOH RTS SUMMARY - &amp;amp;worddt"; 
			
endcomp;
compute AGENCYNAME;
	I + 1;
	if mod(i,2) eq 1 then
	call define(_row_, "style", "style=[background=%RGB(230,230,230)]");
endcomp;
compute after;
	AGENCYNAME = 'Total';
	call define (_row_,'style','style=[backgroundcolor=lightgray foreground=black]');
endcomp;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lisa_Sessions_2-1651840564857.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71188iD6D7EE6599095052/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Lisa_Sessions_2-1651840564857.png" alt="Lisa_Sessions_2-1651840564857.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 06 May 2022 12:37:42 GMT</pubDate>
    <dc:creator>LMSSAS</dc:creator>
    <dc:date>2022-05-06T12:37:42Z</dc:date>
    <item>
      <title>Calculating Avg at column level for total of Avg's</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Avg-at-column-level-for-total-of-Avg-s/m-p/811861#M320268</link>
      <description>&lt;P&gt;Hello - I created a table and proc report, code below and image of table.&amp;nbsp; &amp;nbsp;I calculated "AVG APPS RTS" by dividing "Total Contracted&amp;nbsp; / Ready To Sell" at the row level. how do I get the&amp;nbsp;"AVG APPS RTS" at the column level so that in the total bar at the bottom of my table&amp;nbsp; it shows the&amp;nbsp;"AVG APPS RTS" instead as a sum of the rows?&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; create table TOHFinal as
Select Distinct
a.AGENCYNAME,
b.AHIPNeeded format=comma10., 
c.ReadyToTrain format=comma10.,
d.ReadyToSell format=comma10.,
sum(b.AHIPNeeded,c.ReadyToTrain,d.ReadyToSell) as TotalContracted format=comma10.,
0 as '2022 Sales Goal'n,
a.'2022 Sales'n format=comma10.,
calculated TotalContracted/d.ReadyToSell as Avg_Apps_RTS format=comma10.2,
today() as Rundate Format=MMDDYYS10.
From Active_Count2 a
left join Count_AHIPNeeded_TOH b 
on a.TOH_AGENCY=b.TOH_AGENCY
left join Count_ReadyToTrain_TOH c 
on a.TOH_AGENCY=c.TOH_AGENCY
left join Count_ReadyToSell_TOH d 
on a.TOH_AGENCY=d.TOH_AGENCY
Where a.AGENCYNAME is not Null 
;
quit;

proc report data=TOHFinal  nowd split='|' spanrows
style(header) = [font=("Arial",10.0pt) vjust=middle just=center background=%RGB(0,145,204) foreground=whitesmoke font_weight=bold];
   cols AGENCYNAME AHIPNEEDED READYTOTRAIN READYTOSELL TOTALCONTRACTED '2022 SALES GOAL'n '2022 SALES'n AVG_APPS_RTS;

	define AGENCYNAME / "AGENCY NAME" order=data ;
	define AHIPNEEDED / "AHIP NEEDED" style(column)={vjust=c just=c cellwidth = 1in} order=data;
	define READYTOTRAIN / "READY | TO TRAIN" style(column)={vjust=c just=c cellwidth = 1in};
	define READYTOSELL / "READY | TO SELL" style(column)={vjust=c just=c cellwidth = 1in};
	define TOTALCONTRACTED / "TOTAL CONTRACTED" style(column)={vjust=c just=c cellwidth = 1in} order=data ;
	define '2022 SALES GOAL'n / "2022 SALES GOAL" style(column)={vjust=c just=c cellwidth = 1in} order=data;
	define '2022 SALES'n / "2022 | SALES" style(column)={vjust=c just=c cellwidth = 1in};
	define AVG_APPS_RTS / "AVG | APPS RTS" style(column)={vjust=c just=c cellwidth = 1in};           
	rbreak after /summarize  style=[fontweight=bold];
	compute before _page_/style=[font=("Arial",12.5pt) vjust=middle just=center background=whitesmoke foreground=%RGB(0,145,204) font_weight=bold borderbottomcolor=%RGB(242,242,242)];
	 line "WEEKLY TOH RTS SUMMARY - &amp;amp;worddt"; 
			
endcomp;
compute AGENCYNAME;
	I + 1;
	if mod(i,2) eq 1 then
	call define(_row_, "style", "style=[background=%RGB(230,230,230)]");
endcomp;
compute after;
	AGENCYNAME = 'Total';
	call define (_row_,'style','style=[backgroundcolor=lightgray foreground=black]');
endcomp;

run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Lisa_Sessions_2-1651840564857.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71188iD6D7EE6599095052/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Lisa_Sessions_2-1651840564857.png" alt="Lisa_Sessions_2-1651840564857.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 12:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Avg-at-column-level-for-total-of-Avg-s/m-p/811861#M320268</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-05-06T12:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating Avg at column level for total of Avg's</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculating-Avg-at-column-level-for-total-of-Avg-s/m-p/817208#M322564</link>
      <description>&lt;P&gt;For the columns you want a total average calculated add MEAN.&amp;nbsp; The default is SUM.&lt;/P&gt;
&lt;P&gt;define varname / mean ;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jun 2022 20:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculating-Avg-at-column-level-for-total-of-Avg-s/m-p/817208#M322564</guid>
      <dc:creator>JOL</dc:creator>
      <dc:date>2022-06-08T20:02:01Z</dc:date>
    </item>
  </channel>
</rss>

