BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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.
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
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]
deleted_user
Not applicable
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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2033 views
  • 0 likes
  • 2 in conversation