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;
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:
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:
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
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:
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:
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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.