The SAS Output Delivery System and reporting techniques

Text wrapping behaves differently between ODS PDF and RTF using SPANROWS

Reply
N/A
Posts: 0

Text wrapping behaves differently between ODS PDF and RTF using SPANROWS

hi,
I am using PROC REPORT with ODS to produce tables in pdf and rtf format. SPANROWS OPTION is used to combine cells with the same value of group variable. This help produce a nice table. However, if column width is fixed and the character string as the value of group variable is too long, the string will be wrapped into several lines. For output tables in rtf, the result looks something like this,
col1.........col2.......col3
this is......12.0.......22
a long......34.0.......33
string...... 56.0.......44

which is fine. However, for output tables in pdf, the result does not looks so good:
col1.........col2......col3
this is......12.0......22
a long
string
...............34.0......33
...............56.0......44
which has some blank spaces in col2 and col3.

Anyone know how to avoid such blank spaces in pdf, please advise. Thanks.
SAS Super FREQ
Posts: 8,743

Re: Text wrapping behaves differently between ODS PDF and RTF using SPANROWS

Hi:
I never noticed that behavior of PDF with SPANROWS, but you're right, PDF resizes the first cell in the spanned rows to fit the whole text.

I don't know exactly whether this is the recommended method, but this worked for me (see #3 below).

Otherwise, if this method doesn't work for you or you prefer to find another method, you might want to work with Tech Support on this issue.

cynthia
[pre]
data class;
set sashelp.class;
where age ge 14;
length grpline $100;
grpline = sex||' ~ Twas brillig and the slithy toves '||
'Did gyre and gimble in the wabe.';
run;

** 1) take all defaults with spanrows;
ods rtf file='c:\temp\testspan1.rtf';
ods pdf file='c:\temp\testspan1.pdf';

proc report data=class nowd spanrows;
title '1) do not control cell width';
column grpline name age height;
define grpline / group;
define name / order;
define age / display;
define height / display;
run;
ods _all_ close;

** 2) use CELLWIDTH to see wrapping differences;
ods rtf file='c:\temp\testspan2.rtf';
ods pdf file='c:\temp\testspan2.pdf';

proc report data=class nowd spanrows;
title '2) use cell width control';
column grpline name age height;
define grpline / group style(column)={cellwidth=2in};
define name / order;
define age / display;
define height / display;
run;
ods _all_ close;

** 3) use CELLHEIGHT with ODS PDF;
ods pdf file='c:\temp\testspan3.pdf';

proc report data=class nowd spanrows
style(column)={cellheight=14pt};
title '3) use cell width control with PDF';
column grpline name age height;
define grpline / group style(column)={cellwidth=2in cellheight=14pt};
define name / order;
define age / display;
define height / display;
run;
ods _all_ close;
[/pre]
N/A
Posts: 0

Re: Text wrapping behaves differently between ODS PDF and RTF using SPANROWS

Thanks you very much, Cynthia.
The mothod you suggested works in all cases except when the text string spans across too many lines and the number of corresponding rows in other columns is limited. In that case, the text string will be truncated.

Anyway, this method is good enough for me. Thanks again.
Ask a Question
Discussion stats
  • 2 replies
  • 354 views
  • 0 likes
  • 2 in conversation