<?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 proc report summary for group at the end in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-report-summary-for-group-at-the-end/m-p/720881#M223348</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;I'm calling the expert directly. I've learnt a lot from your papers and your answers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm quite happy with the output but I'm struggling to get final summary lines for the 5 products I have at the end of the report before the grand total.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the second group 'product' should create 5 lines at the end of the report summarizing for each product.&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="rep2.png" style="width: 793px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55023iFBA6D6AACD9F82D6/image-size/large?v=v2&amp;amp;px=999" role="button" title="rep2.png" alt="rep2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods _all_ close;
ods excel file='/caslibs/marketing/vw_kpi_dealer_retail_report_v2.xlsx';
proc report data=public.sum2(rename=(fin_sum=fin ren_sum=ren)) nowd center split="*" out=three completerows;
where year(month) ge 2020 and lowcase(from_brand)="audi";
by from_brand year;
format 'month'n monyy.;
column from_dig5 show_from_dig5 producto  'month'n,   (fin ren mkpi ) fin=tot1  ren=tot kpi ;
define from_dig5 / group noprint  ;
define show_from_dig5 / computed f=$14. 'Dealer code' left;
define 'month'n / 'quarter*(1)' center order=internal across;
define producto / group 'product*(2)' center;
define fin / analysis sum  'Finalizados*(1)' ;
define ren / analysis sum  'Renovados*(2)'   ;
define tot / analysis sum  'YTD Renovados*(4)' ;
define tot1 / analysis sum  'YTD Finalizados*(5)' ;
define kpi / computed f=percent9.1 'ytd KPI*(6)' style(column)={background=fpcta.};
define mkpi / computed f=percent9.1 'KPI*(3)' style(column)={background=fpcta.};

break after from_dig5 / summarize style=Header;


  compute before from_dig5;
    length holdval $25;
	holdval = from_dig5;
  endcomp;
  compute show_from_dig5/character length=25;
    show_from_dig5 = holdval;
	if upcase(_break_) = 'FROM_DIG5' then
	  show_from_dig5 = catx(' ', show_from_dig5,'Total');
  endcomp;

compute kpi;
kpi = tot / tot1;
endcomp;

compute mkpi;
_c6_=_c5_/_c4_;_c9_=_c8_/_c7_;_c12_=_c11_/_c10_;_c15_=_c14_/_c13_;_c18_=_c17_/_c16_;_c21_=_c20_/_c19_;_c24_=_c23_/_c22_;
_c27_=_c26_/_c25_;_c30_=_c29_/_c28_;_c33_=_c32_/_c31_;_c36_=_c35_/_c34_;_c39_=_c38_/_c37_;
endcomp;

rbreak after / summarize ul ol;

run;

ods _all_ close;
ods listing;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 22 Feb 2021 11:57:41 GMT</pubDate>
    <dc:creator>acordes</dc:creator>
    <dc:date>2021-02-22T11:57:41Z</dc:date>
    <item>
      <title>proc report summary for group at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-summary-for-group-at-the-end/m-p/720881#M223348</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt;&amp;nbsp;I'm calling the expert directly. I've learnt a lot from your papers and your answers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm quite happy with the output but I'm struggling to get final summary lines for the 5 products I have at the end of the report before the grand total.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the second group 'product' should create 5 lines at the end of the report summarizing for each product.&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="rep2.png" style="width: 793px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55023iFBA6D6AACD9F82D6/image-size/large?v=v2&amp;amp;px=999" role="button" title="rep2.png" alt="rep2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods _all_ close;
ods excel file='/caslibs/marketing/vw_kpi_dealer_retail_report_v2.xlsx';
proc report data=public.sum2(rename=(fin_sum=fin ren_sum=ren)) nowd center split="*" out=three completerows;
where year(month) ge 2020 and lowcase(from_brand)="audi";
by from_brand year;
format 'month'n monyy.;
column from_dig5 show_from_dig5 producto  'month'n,   (fin ren mkpi ) fin=tot1  ren=tot kpi ;
define from_dig5 / group noprint  ;
define show_from_dig5 / computed f=$14. 'Dealer code' left;
define 'month'n / 'quarter*(1)' center order=internal across;
define producto / group 'product*(2)' center;
define fin / analysis sum  'Finalizados*(1)' ;
define ren / analysis sum  'Renovados*(2)'   ;
define tot / analysis sum  'YTD Renovados*(4)' ;
define tot1 / analysis sum  'YTD Finalizados*(5)' ;
define kpi / computed f=percent9.1 'ytd KPI*(6)' style(column)={background=fpcta.};
define mkpi / computed f=percent9.1 'KPI*(3)' style(column)={background=fpcta.};

break after from_dig5 / summarize style=Header;


  compute before from_dig5;
    length holdval $25;
	holdval = from_dig5;
  endcomp;
  compute show_from_dig5/character length=25;
    show_from_dig5 = holdval;
	if upcase(_break_) = 'FROM_DIG5' then
	  show_from_dig5 = catx(' ', show_from_dig5,'Total');
  endcomp;

compute kpi;
kpi = tot / tot1;
endcomp;

compute mkpi;
_c6_=_c5_/_c4_;_c9_=_c8_/_c7_;_c12_=_c11_/_c10_;_c15_=_c14_/_c13_;_c18_=_c17_/_c16_;_c21_=_c20_/_c19_;_c24_=_c23_/_c22_;
_c27_=_c26_/_c25_;_c30_=_c29_/_c28_;_c33_=_c32_/_c31_;_c36_=_c35_/_c34_;_c39_=_c38_/_c37_;
endcomp;

rbreak after / summarize ul ol;

run;

ods _all_ close;
ods listing;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Feb 2021 11:57:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-summary-for-group-at-the-end/m-p/720881#M223348</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2021-02-22T11:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: proc report summary for group at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-summary-for-group-at-the-end/m-p/721659#M223705</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Sorry for not responding sooner. Apparently the "@mention" is more than a "like". I'm not sure I really understand your report. Your code is nice to see, but since the structure of the data makes a difference, it would be useful to have test data. I don't understand why you are using named literal for the month variable ('month'n) when the variable name does not have any special characters or spaces. You don't show your format. Not clear what the numbers on the columns mean. Based on your COMPUTE block, I would expect many more columns than you show in your screen shot especially if your MKPI item is being calculated under the ACROSS down to _C39_ -- that is a much wider report than your screen shot shows.Without seeing the data, I'm not sure why you're using COMPLETEROWS, or why you are using the OUT= option. You have 2 break lines: a BREAK after from_dig5 and an RBREAK at the bottom of the report. Without knowing what you expect, the 2 statements seem to me to be working correctly. What else do you expect?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Why is Dealer redacted or made black. I don't see that in your program?&amp;nbsp; Also, options like OL and UL on the BREAK or RBREAK statements are completely ignored by ODS destinations.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Finally, I have no idea, at all what you mean when you say you want the " final summary lines for the 5 products I have at the end of the report before the grand total." What are you expecting to see. It looks like BREAK and RBREAK are working correctly to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Sorry I only have questions. But perhaps my questions will point you toward more of a solution.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 18:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-summary-for-group-at-the-end/m-p/721659#M223705</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-02-24T18:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc report summary for group at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-summary-for-group-at-the-end/m-p/721692#M223709</link>
      <description>&lt;P&gt;My fault.&lt;/P&gt;
&lt;P&gt;I blacked these cells due to confidentiality concerns.&lt;/P&gt;
&lt;P&gt;It has 12 months for a full year, but I showed only 2021 with one month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I update the code and add fictitious data created with the data2datastep trick (thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;, works like a charm).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13549"&gt;@Cynthia_sas&lt;/a&gt; I want the second group variable (product) to have a global summary before ending with the grand total.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data PUBLIC.SUM4;
  infile datalines dsd truncover;
  input producto:$20. from_dig5:$5. month:MONYY. year:32. _TYPE_:32. _FREQ_:32. ren_Sum:BEST12. fin_Sum:BEST12. kpi:32. from_dig:32.;
datalines4;
Lineal,X97 3,JAN20,2020,31,10,,10,,
Lineal,X97 3,FEB20,2020,31,14,,14,,
Lineal,X97 3,MAR20,2020,31,9,,9,,
Lineal,X97 3,APR20,2020,31,6,,6,,
Lineal,X97 3,MAY20,2020,31,9,,9,,
Lineal,X97 3,JUN20,2020,31,6,1,5,0.2,
Lineal,X97 3,JUL20,2020,31,11,1,10,0.1,
Lineal,X97 3,AUG20,2020,31,4,,4,,
Lineal,X97 3,SEP20,2020,31,7,,7,,
Lineal,X97 3,OCT20,2020,31,9,,9,,
Lineal,X97 3,NOV20,2020,31,8,,8,,
Lineal,X97 3,DEC20,2020,31,8,1,7,0.1428571429,
Lineal,X97 3,JAN21,2021,31,9,,9,,
Lineal,X97 3,JAN20,2020,31,11,2,9,0.2222222222,
Lineal,X97 3,FEB20,2020,31,7,,7,,
Lineal,X97 3,MAR20,2020,31,10,,10,,
Lineal,X97 3,APR20,2020,31,5,,5,,
Lineal,X97 3,MAY20,2020,31,4,,4,,
Lineal,X97 3,JUN20,2020,31,7,,7,,
Lineal,X97 3,JUL20,2020,31,10,,10,,
Lineal,X97 3,AUG20,2020,31,8,,8,,
Lineal,X97 3,SEP20,2020,31,7,1,6,0.1666666667,
Lineal,X97 3,OCT20,2020,31,8,,8,,
Lineal,X97 3,NOV20,2020,31,10,,10,,
Lineal,X97 3,DEC20,2020,31,9,1,8,0.125,
Lineal,X97 3,JAN21,2021,31,7,,7,,
Lineal,X00 3,JAN20,2020,31,18,2,16,0.125,
Lineal,X00 3,FEB20,2020,31,15,1,14,0.0714285714,
Lineal,X00 3,MAR20,2020,31,12,,12,,
Lineal,X00 3,APR20,2020,31,16,,16,,
Lineal,X00 3,MAY20,2020,31,17,,17,,
Lineal,X00 3,JUN20,2020,31,12,,12,,
Lineal,X00 3,JUL20,2020,31,33,3,30,0.1,
Lineal,X00 3,AUG20,2020,31,17,2,15,0.1333333333,
Lineal,X00 3,SEP20,2020,31,19,,19,,
Lineal,X00 3,OCT20,2020,31,16,,16,,
Lineal,X00 3,NOV20,2020,31,22,1,21,0.0476190476,
Lineal,X00 3,DEC20,2020,31,17,1,16,0.0625,
Lineal,X00 3,JAN21,2021,31,13,1,12,0.0833333333,
Lineal,X00 3,JAN20,2020,31,1,,1,,
Lineal,X00 3,FEB20,2020,31,2,,2,,
Lineal,X00 3,MAR20,2020,31,1,,1,,
Lineal,X00 3,APR20,2020,31,2,,2,,
Lineal,X00 3,MAY20,2020,31,1,,1,,
Lineal,X00 3,JUN20,2020,31,2,,2,,
Lineal,X00 3,JUL20,2020,31,8,,8,,
Lineal,X00 3,AUG20,2020,31,5,,5,,
Lineal,X00 3,SEP20,2020,31,7,,7,,
Lineal,X00 3,OCT20,2020,31,3,,3,,
Lineal,X00 3,NOV20,2020,31,5,,5,,
Lineal,X00 3,DEC20,2020,31,13,,13,,
Lineal,X00 3,JAN21,2021,31,2,,2,,
Lineal,X03 9,DEC20,2020,31,3,,3,,
Lineal,X08 3,JAN20,2020,31,1,,1,,
Lineal,X08 3,FEB20,2020,31,3,,3,,
Lineal,X08 3,MAR20,2020,31,4,,4,,
Lineal,X08 3,APR20,2020,31,3,,3,,
Lineal,X08 3,MAY20,2020,31,2,,2,,
Lineal,X08 3,JUN20,2020,31,3,,3,,
Lineal,X08 3,JUL20,2020,31,7,,7,,
Lineal,X08 3,AUG20,2020,31,2,,2,,
Lineal,X08 3,SEP20,2020,31,7,,7,,
Lineal,X08 3,OCT20,2020,31,1,,1,,
Lineal,X08 3,NOV20,2020,31,5,,5,,
Lineal,X08 3,DEC20,2020,31,2,,2,,
Other,X97 3,MAY20,2020,31,1,,1,,
Other,X97 3,JAN21,2021,31,1,,1,,
Renting,X92 3,APR20,2020,31,1,,1,,
Renting,X92 3,JUN20,2020,31,1,,1,,
Renting,X92 3,AUG20,2020,31,2,1,1,1,
Renting,X92 3,OCT20,2020,31,1,1,,,
Renting,X92 3,NOV20,2020,31,1,,1,,
Renting,X92 3,APR20,2020,31,1,,1,,
Renting,X92 3,JUL20,2020,31,1,,1,,
Renting,X92 3,SEP20,2020,31,1,,1,,
Renting,X92 3,NOV20,2020,31,1,1,,,
Renting,X92 3,DEC20,2020,31,1,,1,,
Renting,X92 3,JAN21,2021,31,2,1,1,1,
Lineal,X92 3,JAN20,2020,31,11,,11,,
Lineal,X92 3,FEB20,2020,31,10,,10,,
Lineal,X92 3,MAR20,2020,31,5,,5,,
Lineal,X92 3,APR20,2020,31,5,,5,,
Lineal,X92 3,MAY20,2020,31,7,,7,,
Lineal,X92 3,JUN20,2020,31,4,,4,,
Lineal,X92 3,JUL20,2020,31,8,,8,,
Lineal,X92 3,AUG20,2020,31,6,,6,,
Lineal,X92 3,SEP20,2020,31,9,,9,,
Lineal,X92 3,OCT20,2020,31,11,,11,,
Lineal,X92 3,NOV20,2020,31,14,,14,,
Lineal,X92 3,DEC20,2020,31,5,,5,,
Lineal,X92 3,JAN21,2021,31,6,,6,,
Lineal,X92 3,JAN20,2020,31,17,,17,,
Lineal,X92 3,FEB20,2020,31,16,2,14,0.1428571429,
Lineal,X92 3,MAR20,2020,31,19,,19,,
Lineal,X92 3,APR20,2020,31,17,,17,,
Lineal,X92 3,MAY20,2020,31,13,,13,,
Lineal,X92 3,JUN20,2020,31,24,2,22,0.0909090909,
Lineal,X92 3,JUL20,2020,31,28,,28,,
Lineal,X92 3,AUG20,2020,31,13,,13,,
Lineal,X92 3,SEP20,2020,31,21,1,20,0.05,
Lineal,X92 3,OCT20,2020,31,12,,12,,
Lineal,X92 3,NOV20,2020,31,21,,21,,
Lineal,X92 3,DEC20,2020,31,15,,15,,
Lineal,X92 3,JAN21,2021,31,17,,17,,
CPC,X92 3,FEB20,2020,31,1,,1,,
CPC,X92 3,MAR20,2020,31,1,,1,,
CPC,X92 3,JUN20,2020,31,1,,1,,
CPC,X92 3,SEP20,2020,31,2,,2,,
CPC,X92 3,NOV20,2020,31,1,,1,,
CPC,X92 3,DEC20,2020,31,2,,2,,
CPC,X92 3,JAN21,2021,31,1,,1,,
CPC,X92 3,JUN20,2020,31,1,,1,,
CPC,X92 3,JUL20,2020,31,2,,2,,
CPC,X92 3,AUG20,2020,31,1,,1,,
CPC,X92 3,SEP20,2020,31,1,,1,,
CPC,X97 3,JAN20,2020,31,1,1,,,
CPC,X97 3,FEB20,2020,31,1,,1,,
CPC,X97 3,JUN20,2020,31,1,,1,,
CPC,X97 3,JAN21,2021,31,1,,1,,
CPC,X97 3,MAY20,2020,31,2,,2,,
CPC,X97 3,JUN20,2020,31,1,,1,,
CPC,X97 3,AUG20,2020,31,1,,1,,
CPC,X97 3,SEP20,2020,31,1,,1,,
CPC,X00 3,JAN20,2020,31,1,,1,,
CPC,X00 3,MAR20,2020,31,2,1,1,1,
CPC,X00 3,APR20,2020,31,3,,3,,
CPC,X00 3,MAY20,2020,31,1,,1,,
CPC,X00 3,JUN20,2020,31,3,,3,,
CPC,X00 3,JUL20,2020,31,3,,3,,
CPC,X00 3,AUG20,2020,31,2,,2,,
CPC,X00 3,SEP20,2020,31,1,,1,,
CPC,X00 3,OCT20,2020,31,2,,2,,
CPC,X00 3,NOV20,2020,31,3,1,2,0.5,
CPC,X00 3,DEC20,2020,31,1,,1,,
CPC,X00 3,FEB20,2020,31,1,,1,,
CPC,X00 3,APR20,2020,31,1,,1,,
CPC,X00 3,JUN20,2020,31,2,,2,,
CPC,X00 3,SEP20,2020,31,1,,1,,
CPC,X00 3,NOV20,2020,31,1,,1,,
CPC,X08 3,JAN20,2020,31,1,,1,,
CPC,X08 3,JUN20,2020,31,1,,1,,
CPC,X08 3,AUG20,2020,31,1,,1,,
Lineal,X94 3,JAN20,2020,31,2,,2,,
Lineal,X94 3,FEB20,2020,31,2,,2,,
Lineal,X94 3,MAR20,2020,31,3,,3,,
Lineal,X94 3,APR20,2020,31,1,,1,,
Lineal,X94 3,MAY20,2020,31,3,,3,,
Lineal,X94 3,JUN20,2020,31,4,,4,,
Lineal,X94 3,JUL20,2020,31,2,,2,,
Lineal,X94 3,AUG20,2020,31,7,,7,,
Lineal,X94 3,SEP20,2020,31,1,,1,,
Lineal,X94 3,NOV20,2020,31,1,,1,,
Lineal,X94 3,DEC20,2020,31,2,,2,,
Lineal,X94 3,JAN21,2021,31,3,,3,,
Renting,X97 3,JAN20,2020,31,2,1,1,1,
Renting,X97 3,FEB20,2020,31,1,,1,,
Renting,X97 3,MAR20,2020,31,1,,1,,
Renting,X97 3,APR20,2020,31,1,,1,,
Renting,X97 3,MAY20,2020,31,1,1,,,
Renting,X97 3,JUN20,2020,31,1,,1,,
Renting,X97 3,JUL20,2020,31,1,1,,,
Renting,X97 3,SEP20,2020,31,3,2,1,2,
Renting,X97 3,OCT20,2020,31,2,,2,,
Renting,X97 3,NOV20,2020,31,3,,3,,
Renting,X97 3,DEC20,2020,31,2,,2,,
Renting,X97 3,JAN21,2021,31,2,,2,,
Renting,X97 3,JUN20,2020,31,1,,1,,
Renting,X97 3,JAN21,2021,31,1,,1,,
Renting,X00 3,JAN20,2020,31,1,,1,,
Renting,X00 3,JUL20,2020,31,1,,1,,
Renting,X00 3,AUG20,2020,31,1,1,,,
Renting,X00 3,SEP20,2020,31,1,,1,,
Renting,X00 3,OCT20,2020,31,1,,1,,
Renting,X00 3,NOV20,2020,31,1,,1,,
Renting,X00 3,JAN21,2021,31,1,,1,,
Renting,X00 3,APR20,2020,31,1,,1,,
Renting,X03 8,AUG20,2020,31,1,,1,,
Renting,X08 3,FEB20,2020,31,1,,1,,
Renting,X08 3,OCT20,2020,31,1,1,,,
Renting,X08 3,NOV20,2020,31,1,,1,,
;;;;
run;


ods _all_ close;
ods excel file='/caslibs/marketing/test_kpi_dealer_retail_report_v2.xlsx';
proc report data=public.sum4(rename=(fin_sum=fin ren_sum=ren)) nowd center split="*" out=three completerows;
by year;
format 'month'n monyy.;
column from_dig5 show_from_dig5 producto  'month'n,   (fin ren mkpi ) fin=tot1  ren=tot kpi ;
define from_dig5 / group noprint  ;
define show_from_dig5 / computed f=$14. 'Dealer code' left;
define 'month'n / 'quarter*(1)' center order=internal across;
define producto / group 'product*(2)' center;
define fin / analysis sum  'Finalizados*(1)' ;
define ren / analysis sum  'Renovados*(2)'   ;
define tot / analysis sum  'YTD Renovados*(4)' ;
define tot1 / analysis sum  'YTD Finalizados*(5)' ;
define kpi / computed f=percent9.1 'ytd KPI*(6)' style(column)={background=fpcta.};
define mkpi / computed f=percent9.1 'KPI*(3)' style(column)={background=fpcta.};

break after from_dig5 / summarize style=Header;


  compute before from_dig5;
    length holdval $25;
	holdval = from_dig5;
  endcomp;
  compute show_from_dig5/character length=25;
    show_from_dig5 = holdval;
	if upcase(_break_) = 'FROM_DIG5' then
	  show_from_dig5 = catx(' ', show_from_dig5,'Total');
	if upcase(_break_) = '_RBREAK_' then
	  show_from_dig5 = 'Grand Total';
  endcomp;

compute kpi;
kpi = tot / tot1;
endcomp;

compute mkpi;
_c6_=_c5_/_c4_;_c9_=_c8_/_c7_;_c12_=_c11_/_c10_;_c15_=_c14_/_c13_;_c18_=_c17_/_c16_;_c21_=_c20_/_c19_;_c24_=_c23_/_c22_;
_c27_=_c26_/_c25_;_c30_=_c29_/_c28_;_c33_=_c32_/_c31_;_c36_=_c35_/_c34_;_c39_=_c38_/_c37_;
endcomp;

rbreak after / summarize ul ol;

run;

ods _all_ close;
ods listing;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 21:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-summary-for-group-at-the-end/m-p/721692#M223709</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2021-02-24T21:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: proc report summary for group at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-summary-for-group-at-the-end/m-p/721725#M223728</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt;-- don't have format &lt;STRONG&gt;fpcta&lt;/STRONG&gt; for style override on background in your code&lt;BR /&gt;-- get error because &lt;STRONG&gt;public.sum4&lt;/STRONG&gt; is not sorted by &lt;STRONG&gt;year&lt;/STRONG&gt;&lt;BR /&gt;-- &lt;STRONG&gt;KPI&lt;/STRONG&gt; variable is created in your INPUT statement, but you also have KPI listed as &lt;STRONG&gt;COMPUTED&lt;/STRONG&gt; in the PROC REPORT step. This generates NOTES that indicate output might not be desirable and I agree...I don't understand why you're reading KPI from the input file and then overwriting it with your own calculation. These are the NOTES:&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;&lt;STRONG&gt;NOTE: The computed variable kpi is also a data set variable.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier" color="#0000FF"&gt;&lt;STRONG&gt;NOTE: The output might not be as expected.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;-- even correcting for some of the above, I have NO idea what you mean by a "global summary" of the products before the grand total. That is not what PROC REPORT will do. In your test data, I see 4 unique values for PRODUCTO:&lt;BR /&gt;producto &lt;BR /&gt;CPC 38 &lt;BR /&gt;Lineal 103 &lt;BR /&gt;Other 2 &lt;BR /&gt;Renting 37 &lt;BR /&gt;&lt;BR /&gt;The way you have your report structured, you have THIS in your column statement:&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;column &lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt;from_dig5&lt;/FONT&gt; &lt;/STRONG&gt;show_from_dig5&lt;STRONG&gt;&lt;FONT color="#FF00FF"&gt; producto&lt;/FONT&gt;&lt;/STRONG&gt; month, (fin ren mkpi ) fin=tot1 ren=tot kpi ;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;So even if FROM_DIG5 is NOPRINT, it is still a GROUP item and the PRODUCTO values are nested "inside" each FROM_DIG5 group. That is what I see. The way you have your COLUMN statement is not going to allow a separate summary for PRODUCTO. &lt;BR /&gt;&lt;BR /&gt;Correcting for all the missing parts of your code and ignoring ODS EXCEL in the interests of simplicity, here's what I get for 2021 -- subtotals are yellow and Grand total is blue like the headers:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1614216971713.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55138i68124BEFD849E676/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1614216971713.png" alt="Cynthia_sas_0-1614216971713.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I think you might envision some kind of separate summary for PRODUCTO without regard to FROM_DIG5, maybe between the last yellow subtotal and the final GRAND TOTAL but that would be a separate PROC REPORT step, if you did not want FROM_DIG5 to be used as the primary group, then you'd need to drop it and the other logic from your code. Here's an example of what I envision by "global summary" of PRODUCTO for 2021 just showing summaries for PRODUCTO without regard to FROM_DIG5:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_1-1614217015851.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55139i6ACFAFA2D189DEDE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_1-1614217015851.png" alt="Cynthia_sas_1-1614217015851.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Maybe this will help you figure out what you can and can't do with PROC REPORT.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Cynthia&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;:&lt;/P&gt;</description>
      <pubDate>Thu, 25 Feb 2021 01:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-summary-for-group-at-the-end/m-p/721725#M223728</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-02-25T01:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc report summary for group at the end</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-report-summary-for-group-at-the-end/m-p/721773#M223749</link>
      <description>That was my question. &lt;BR /&gt;And the answer is clear. I have to do it separately. &lt;BR /&gt;" if you did not want FROM_DIG5 to be used as the primary group, then you'd need to drop it and the other logic from your code. Here's an example of what I envision by "global summary" of PRODUCTO for 2021 just showing summaries for PRODUCTO without regard to FROM_DIG5:"</description>
      <pubDate>Thu, 25 Feb 2021 07:57:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-report-summary-for-group-at-the-end/m-p/721773#M223749</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2021-02-25T07:57:40Z</dc:date>
    </item>
  </channel>
</rss>

