BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I am trying to use the Split='#' option in a report but when using this with the ODS RTF output it fails to work for the data within the columns. It does split the column labels correctly but it doesn't seem to recognize the split character '#' within the column.
Does anyone know if it is possible to use the split option in ODS RTF like this and if not is there another trick I can use to correctly split my data within columns?
Thanks
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi:
PROC REPORT's SPLIT= option is intended for use with column headers (not data cells). If you want to insert a line break into a data cell, your choices are:
1) ODS ESCAPECHAR methods (either 9.1.3 method or 9.2 method)
2) RTF control string method (using \line RTF command)

The program below shows these methods in comparison to trying to use the SPLIT character in a data cell. Note that if you run this program in SAS 9.1.3, the 9.2 ESCAPECHAR method will not work for you. Also, I put the concatenated NAME variables in a DATA step program. I could just as easily have put them in a COMPUTE block, but it's easier to compare the 4 creation methods in a DATA step program.

cynthia
[pre]
data class;
length name1-name4 $40;
set sashelp.class;
name1 = catx(' ~n',name,put(_n_,z2.0),sex);
name2 = catx(' {\line}',name,put(_n_,z2.0),sex);
name3 = catx(' ~{newline 1}',name,put(_n_,z2.0),sex);
name4 = catx('#',name,put(_n_,z2.0),sex);
label name1='Name#Line Break#with Escapechar'
name2='Name#Line Break#with RTF control string'
name3='Name#Line Break#with 9.2 Escapechar'
name4='Try PROC REPORT Split Char in Data Cell';
run;

ods listing close;
ods rtf file='c:\temp\test_linebrk.rtf';
ods escapechar='~';
proc report data=class nowd split='#';
title 'Show Different Methods';
column name1 name2 name3 name4;
define name1/ display;
define name2/display style(column)={protectspecialchars=off};
define name3/ display;
define name4/ display;
run;
ods rtf close;
title;
[/pre]
DonZ
Calcite | Level 5

Hi, Cynthia:

Thank you so much for the explanation. I took your cope fragment of "~n", which did work to wrap the text string. However, after the wrapping, the original indent was lost. I have tried may macros shared by public, but none of those could solve the issues. would you please instruct me how to do?

 

Best

Don

 

Example:  desired output:

AAAAAAAAAAAAA

    bbbbbbbbbbbb

    bbbb;    (<----- desired indent)

 

after wrapping: 

AAAAAAAAAAAAA

    bbbbbbbbbbbb

bbbb    (<-------- lost indentation)

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 2 replies
  • 4212 views
  • 0 likes
  • 3 in conversation