BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
YNWA1
Obsidian | Level 7

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? 

I have also provided a test dataset and code

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;

 

YNWA1_0-1631540904425.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  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 table_cnt:

Cynthia_sas_0-1631552270052.png

 Then, the table_cnt variable can be placed on the report row and used in the creation of DISP_LINE, as shown below with partial output:

Cynthia_sas_1-1631552345627.png

 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.

 

  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.

 

Cynthia

View solution in original post

1 REPLY 1
Cynthia_sas
SAS Super FREQ

Hi:

  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 table_cnt:

Cynthia_sas_0-1631552270052.png

 Then, the table_cnt variable can be placed on the report row and used in the creation of DISP_LINE, as shown below with partial output:

Cynthia_sas_1-1631552345627.png

 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.

 

  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.

 

Cynthia

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 313 views
  • 1 like
  • 2 in conversation