<?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 in ODS  - Generate table number in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Report-in-ODS-Generate-table-number/m-p/767413#M39509</link>
    <description>&lt;P&gt;Hi, can someone help to provide a solution on how to generate a table number (see in RED) for each report when using the by condition?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also provided a test dataset and code&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines dlm='';
input EXCEPTION_CODE $6. EXCEPTION $14. num_excpt_split AGE_RANGE $17. lob $2.;
datalines;
TYPE1 Type1Exception 3 '30 days or less' A
TYPE2 Type2Exception 5 '30 to 60 days  ' B
TYPE3 Type3Exception 7 '60 to 90 days  ' C
TYPE4 Type4Exception 8 '90 to 180 days ' D
TYPE5 Type5Exception 9 '180 to 365 days' E
;
run;
OPTIONS NOBYLINE;
proc report data=test nowd;
/*where exception_code='CDV';*/
columns (lob) (AGE_RANGE) (num_excpt_split) exception_code;
define lob/group;
define num_excpt_split/analysis sum "Total" ;
define exception_code/ noprint;
BREAK AFTER lob / SUMMARIZE style={background=VLIGB};
compute after lob;
  call define ('lob','style','style=Header{pretext="TOTAL "}');
endcomp;
compute before _page_ /
          style={just=L font_weight=bold};
    disp_line = exception_code||" Age by LOB (Table A.#)";
    line disp_line $25.;
  endcomp;
label lob="LOB" AGE_RANGE="Period" num_excpt_split="Total";
by EXCEPTION;
Title "Age of #byval1 by LOB";
run;
Title;
OPTIONS BYLINE;&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="YNWA1_0-1631540904425.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63536i5023FB9E3BAE176C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YNWA1_0-1631540904425.png" alt="YNWA1_0-1631540904425.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Sep 2021 13:53:00 GMT</pubDate>
    <dc:creator>YNWA1</dc:creator>
    <dc:date>2021-09-13T13:53:00Z</dc:date>
    <item>
      <title>Proc Report in ODS  - Generate table number</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Report-in-ODS-Generate-table-number/m-p/767413#M39509</link>
      <description>&lt;P&gt;Hi, can someone help to provide a solution on how to generate a table number (see in RED) for each report when using the by condition?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also provided a test dataset and code&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
infile datalines dlm='';
input EXCEPTION_CODE $6. EXCEPTION $14. num_excpt_split AGE_RANGE $17. lob $2.;
datalines;
TYPE1 Type1Exception 3 '30 days or less' A
TYPE2 Type2Exception 5 '30 to 60 days  ' B
TYPE3 Type3Exception 7 '60 to 90 days  ' C
TYPE4 Type4Exception 8 '90 to 180 days ' D
TYPE5 Type5Exception 9 '180 to 365 days' E
;
run;
OPTIONS NOBYLINE;
proc report data=test nowd;
/*where exception_code='CDV';*/
columns (lob) (AGE_RANGE) (num_excpt_split) exception_code;
define lob/group;
define num_excpt_split/analysis sum "Total" ;
define exception_code/ noprint;
BREAK AFTER lob / SUMMARIZE style={background=VLIGB};
compute after lob;
  call define ('lob','style','style=Header{pretext="TOTAL "}');
endcomp;
compute before _page_ /
          style={just=L font_weight=bold};
    disp_line = exception_code||" Age by LOB (Table A.#)";
    line disp_line $25.;
  endcomp;
label lob="LOB" AGE_RANGE="Period" num_excpt_split="Total";
by EXCEPTION;
Title "Age of #byval1 by LOB";
run;
Title;
OPTIONS BYLINE;&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="YNWA1_0-1631540904425.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63536i5023FB9E3BAE176C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YNWA1_0-1631540904425.png" alt="YNWA1_0-1631540904425.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 13:53:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Report-in-ODS-Generate-table-number/m-p/767413#M39509</guid>
      <dc:creator>YNWA1</dc:creator>
      <dc:date>2021-09-13T13:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Report in ODS  - Generate table number</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Report-in-ODS-Generate-table-number/m-p/767486#M39515</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Since you're using BY group processing to get every table separate, I think the easiest thing to do is to calculate a helper variable in a DATA step, as shown below, where I create the variable &lt;STRONG&gt;table_cnt&lt;/STRONG&gt;:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_0-1631552270052.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63545iE9284AB5FCEA9064/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_0-1631552270052.png" alt="Cynthia_sas_0-1631552270052.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Then, the &lt;STRONG&gt;table_cnt&lt;/STRONG&gt; variable can be placed on the report row and used in the creation of DISP_LINE, as shown below with partial output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_1-1631552345627.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63546i87AAF4DF13A0FC73/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_1-1631552345627.png" alt="Cynthia_sas_1-1631552345627.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;After you verify that table_cnt is working as desired, you can use NOPRINT to just hide the column on the report. Note that I added a LENGTH statement for DISP_LINE with a length of 30 because when concatenating, I like to make sure the length will be wide enough to avoid truncation. Then, I also changed the format in the LINE statement to $30. as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I toyed with the idea of using substr to get the number our of the TYPE variable, so that's another possible approach, but I was afraid that this was some dummy data and the real values might not contain a number that corresponds to the table number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 17:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Report-in-ODS-Generate-table-number/m-p/767486#M39515</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2021-09-13T17:02:16Z</dc:date>
    </item>
  </channel>
</rss>

