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;
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.
Have you seen this page?
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.
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.
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.
Thank you @RichardAD . I ended up using this concept. I think we don't any option left other than this.
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.
Ready to level-up your skills? Choose your own adventure.