<?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: How to get percentage rather than sum in Total row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-percentage-rather-than-sum-in-Total-row/m-p/830420#M328121</link>
    <description>Thank you!&lt;BR /&gt;</description>
    <pubDate>Thu, 25 Aug 2022 19:55:27 GMT</pubDate>
    <dc:creator>LMSSAS</dc:creator>
    <dc:date>2022-08-25T19:55:27Z</dc:date>
    <item>
      <title>How to get percentage rather than sum in Total row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-percentage-rather-than-sum-in-Total-row/m-p/830274#M328067</link>
      <description>&lt;P&gt;hello, i use the below code (proc sql and proc report) to create the calcs in my table. I am trying to solve for having the total % Change not be a sum of the % Change column but be a percentage of the total in the 2 columns. it should be 628/1391=45.14% rather than a total of that column. Can someone advise on how to solve for this?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LMSSAS_0-1661431237363.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/74678iD37BBA4ED4A22FB9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LMSSAS_0-1661431237363.png" alt="LMSSAS_0-1661431237363.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; create table FBMI_APPTS5_Output2 as
select distinct 
Agency_Type,
Newly_Appointed as New_Appoint,
RTS_2023 as RTS2023,
RTS2023/New_Appoint as '% Change'n format=percent10.2
from FBMI_APPTS5_Output;
quit;

proc report data=FBMI_APPTS5_Output2 nowd split='|' /* spanrows */
style(header) = [font=("Arial",10.0pt) vjust=middle just=center background=%RGB(0,145,204) foreground=whitesmoke font_weight=bold]
style(column) = [font=("Arial",8.58pt) bordercolor=%RGB(242,242,242) ];

cols Agency_Type New_Appoint RTS2023 '% Change'n;

define Agency_Type / "Agency | Type" order=data ;
define New_Appoint / "Newly Appointed | for PY 2023" style(column)={vjust=c just=c cellwidth = 1in} order=data;
define RTS2023 / "New RTS 2023" order=data ;
define '% Change'n / "% Change" style(column)={vjust=c just=c cellwidth = 1in} ;

rbreak after /summarize  style=[fontweight=bold];

/* Compute block used to create table title */
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 "Comparison of New Agents"; /*%sysfunc(intnx(day,%sysfunc(today()),-7),worddate20.);*/
endcomp;

compute Agency_Type;
	I + 1;
	if mod(i,2) eq 1 then
	call define(_row_, "style", "style=[background=%RGB(230,230,230)]");
endcomp;

compute after;
	Agency_Type = 'Total';
	call define (_row_,'style','style=[backgroundcolor=lightgray foreground=black]');
endcomp;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 12:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-percentage-rather-than-sum-in-Total-row/m-p/830274#M328067</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-08-25T12:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to get percentage rather than sum in Total row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-percentage-rather-than-sum-in-Total-row/m-p/830291#M328074</link>
      <description>&lt;P&gt;Here is an example :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc report data=sashelp.class nowd split='|' /* spanrows */
style(header) = [font=("Arial",10.0pt) vjust=middle just=center   font_weight=bold]
style(column) = [font=("Arial",8.58pt)  ];

cols name weight height change;

define name / display "Agency | Type" order=data ;
define weight /analysis sum "Newly Appointed | for PY 2023" style(column)={vjust=c just=c cellwidth = 1in} order=data;
define height /analysis sum "New RTS 2023" order=data ;
define change/computed "% Change" style(column)={vjust=c just=c cellwidth = 1in} format=percent8.2;

rbreak after /summarize  style=[fontweight=bold];

/* Compute block used to create table title */
compute before _page_/style=[font=("Arial",12.5pt) vjust=middle just=center background=whitesmoke  font_weight=bold ];
line "Comparison of New Agents"; /*%sysfunc(intnx(day,%sysfunc(today()),-7),worddate20.);*/
endcomp;

compute name;
	I + 1;
	if mod(i,2) eq 1 then
	call define(_row_, "style", "style=[background=greyee");
endcomp;

compute after;
	name = 'Total';
	call define (_row_,'style','style=[backgroundcolor=lightgray foreground=black]');
endcomp;

compute change;
change=height.sum/weight.sum;
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="Ksharp_0-1661434323270.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/74684i86E1614939DC2037/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1661434323270.png" alt="Ksharp_0-1661434323270.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 13:32:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-percentage-rather-than-sum-in-Total-row/m-p/830291#M328074</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-08-25T13:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to get percentage rather than sum in Total row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-percentage-rather-than-sum-in-Total-row/m-p/830299#M328080</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;Add the given code after your first Proc SQL. That should serve the purpose.&lt;BR /&gt;If needed modify the proc report.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
update test set '% Change'n=100*(RTS_2023/New_Appoint)
where Agency_type ="Total";
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 13:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-percentage-rather-than-sum-in-Total-row/m-p/830299#M328080</guid>
      <dc:creator>Sajid01</dc:creator>
      <dc:date>2022-08-25T13:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to get percentage rather than sum in Total row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-percentage-rather-than-sum-in-Total-row/m-p/830420#M328121</link>
      <description>Thank you!&lt;BR /&gt;</description>
      <pubDate>Thu, 25 Aug 2022 19:55:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-percentage-rather-than-sum-in-Total-row/m-p/830420#M328121</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-08-25T19:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to get percentage rather than sum in Total row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-get-percentage-rather-than-sum-in-Total-row/m-p/830421#M328122</link>
      <description>Thank you!</description>
      <pubDate>Thu, 25 Aug 2022 19:55:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-get-percentage-rather-than-sum-in-Total-row/m-p/830421#M328122</guid>
      <dc:creator>LMSSAS</dc:creator>
      <dc:date>2022-08-25T19:55:42Z</dc:date>
    </item>
  </channel>
</rss>

