BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASuserlot
Barite | Level 11

I am creating a list for the Traveling; however, when using the proc report to RTf destination, My one customer ID info goes across the multiple pages. Therefore, we want to display Customer ID information across the pages. I tried 'GROUP' , 'ID' or SPANROWS options but no luck.  Any inputs greatly appreciated.

here is the data:

data have;
    length CustomerID $10 Visit $10 TicketNumber $300 Destination $20;
    CustomerID = "CUST000001";
	pageno =1;

    /* Array of U.S. state names */
    array states[50] $20 _temporary_ (
        'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia',
        'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland',
        'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey',
        'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina',
        'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
    );

    call streaminit(123); /* Initialize random number generator for reproducibility */

    do i = 1 to 50;
        Visit = catt("Month", i);
        TicketNumber = "";

        /* Assign a random state as the destination */
        Destination = states[ceil(rand("Uniform") * dim(states))];

        do j = 1 to 15;
            /* Generate a 10-digit numeric part */
            NumPart = put(ceil(rand("Uniform") * 8999999999 + 1000000000), z10.);

            /* Generate two random letters (one uppercase, one lowercase) */
            CharPart = cats(byte(65 + floor(rand("Uniform") * 26)), byte(97 + floor(rand("Uniform") * 26)));

            /* Combine them to form a 12-character ticket number */
            Ticket = cats(NumPart, CharPart);

            if j = 1 then 
                TicketNumber = Ticket;
            else 
                TicketNumber = catx(", ", TicketNumber, Ticket);
        end;

        output;
    end;
    drop i j NumPart CharPart Ticket;
run;
title '';
footnote '';
ods results on;
ods rtf file="C:\Users\want.rtf" style = rtf;

proc report data=have headline headskip missing split="*" style=[outputwidth=100%]
    style(header column)=[asis=on just=l protectspecialchars=off] ;
 	columns pageno CustomerID visit TicketNumber Destination;
    define pageno     / order   order=internal noprint;
    define CustomerID   /  order 'Customer ID' style(header)={just=l} style(column)=[just=l cellwidth=6%] group id;
    define visit	  / group 'Visit' style(header)={just=l} style(column)=[just=l cellwidth=5.1%];
    define TicketNumber	  / group 'ticket number'  style(column)=[just=l cellwidth=2 %];
    define Destination   	  / group 'destination'  
						style(header)={just=l} style(column)=[just=l cellwidth= 3%];    
                       
    break after pageno/page;
 
 	compute after CustomerID /style=[protectspecialchars=off font_size=8pt font_face="Arial"
                                 font_weight=medium];
       line '';
    endcomp;
	compute before CustomerID /style=[protectspecialchars=off font_size=4pt font_face="Arial"
                                 font_weight=medium];
       line '';
    endcomp;

 run;
ods rtf close;

SASuserlot_0-1738345290423.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
RichardAD
Quartz | Level 8

Have you considered using a BY statement?

That will free up more space for the details in Visit, Ticket and Destination.

 

    by CustomerId ;
    
options nobyline ;
title j=l f='Times' "#byvar1=#byval1"  ;

Then either define CustomerId as NOPRINT or remove it from the COLUMNS list.

RichardAD_0-1738515434115.png

 

View solution in original post

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

Have you seen this page?

https://communities.sas.com/t5/ODS-and-Base-Reporting/Get-SUBJECT-id-to-show-on-each-page-of-a-listi...

You need to use the TAGSETS.RTF destination rather than RTF, and the SPANROWS option in PROC REPORT.

These almost-but-not-quite-redundant ODS destinations are anything but clear tbh.

SASuserlot
Barite | Level 11

Thanks, @ChrisNZ , Yes, I saw this page; since our RTF destinations come from the macros , I can not modify them to Tagsets; I ended up using the #byval concepts to display as subtitles. Thank you for your inputs.

RichardAD
Quartz | Level 8

Have you considered using a BY statement?

That will free up more space for the details in Visit, Ticket and Destination.

 

    by CustomerId ;
    
options nobyline ;
title j=l f='Times' "#byvar1=#byval1"  ;

Then either define CustomerId as NOPRINT or remove it from the COLUMNS list.

RichardAD_0-1738515434115.png

 

SASuserlot
Barite | Level 11

Thank you @RichardAD . I ended up using this concept. I think we don't any option left other than this. 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1616 views
  • 4 likes
  • 3 in conversation