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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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