The SAS Output Delivery System and reporting techniques

Text wrapping?

Reply
N/A
Posts: 0

Text wrapping?

I have a description field that is 254 characters in length. How can I force the column to wrap say after 50 characters? The data looks fine if it exports to HTML, but when it goes to PDF, some pages are fine and the field wraps while others do not wrap. In PDF, this causes issues because on one page, all data appears on one page while on others the data is split.
Any suggestions?
TIA
Patrick
SAS Super FREQ
Posts: 8,744

Re: Text wrapping?

Patrick:
What if you had one column value that was composed of all letter 'i' and another column value that was composed of all letter 'w':

iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

Would you still want to wrap the text starting at the 50th character???? The fact is that RTF and PDF and HTML can be made to wrap long columns, but you must use the CELLWIDTH style attribute to accomplish what you want. And that means that the destination won't automatically wrap after the 50th character (as it might in the LISTING window), but will wrap when the proportional font has filled the cell width and there is still more data from the variable value to fill the cell.

The program shown below should illustrate the difference between letting ODS pick the cellwidth and setting a fixed cellwidth with style attributes. If you wanted to ABSOLUTELY force a line feed or line break character after the 50th character in your data value, then you would have to insert the appropriate ODS ESCAPECHAR into the data values after every 50th character. That's a lot of work (in my opinion) when CELLWIDTH will achieve the wrapping with much less effort.

cynthia

[pre]
**** the code;
** first make some data;
data makelong;
length longvar $254;
var1 = 'aaa';
var2 = 'bbb';
tmp = 'iiiiiiiii iiiiiiiii iiiiiiiii iiiiiiiii iiiiiiiii ';
longvar = tmp || tmp || tmp || tmp ||tmp || tmp;
output;
output;
var1 = 'ccc';
var2 = 'ddd';
longvar = translate(longvar,'w', 'i');
output;
output;
var1 = 'eee';
var2 = 'fff';
longvar = translate(longvar,'f', 'w');
output;
output;
var1 = 'ggg';
var2 = 'hhh';
longvar = translate(longvar,'l', 'f');
output;
output;
run;

** probably using the UNIFORM option will NOT;
** make a difference but I show it just in case;
** it MIGHT make a difference in the first PROC REPORT step output.;

ods listing close;
ods pdf(id=1) file='c:\temp\wrapit1.pdf';
ods pdf(id=2) file='c:\temp\wrapit2.pdf' uniform;
ods html file='c:\temp\wrapit.html';
ods rtf file='c:\temp\wrapit.rtf';

proc report data=makelong nowd;
title 'Let ODS decide the Width for Longvar';
column var1 var2 longvar;
define var1 /order;
define var2 /order;
define longvar / display;
run;

proc report data=makelong nowd;
title 'Use CELLWIDTH attribute';
column var1 var2 longvar;
define var1 /order;
define var2 /order;
define longvar / display
style(column)={cellwidth=2in};
run;
ods _all_ close;
title;
[/pre]
N/A
Posts: 0

Re: Text wrapping?

Thanks Cynthia. I'll give CELLWIDTH a shot and let you know.
N/A
Posts: 0

Re: Text wrapping?

Still didn't work. I even truncated the column down to 30 characters just to test. The report still breaks even though it doesn't need to. I narrow it down to a particular set of data. If this data is not in the report, the output is fine. Once this data added back, that section of the report causes it to go to the next page.
SAS Super FREQ
Posts: 8,744

Re: Text wrapping?

Hi, Patrick:
Are you saying that CELLWIDTH did not work? Or, are you saying that CELLWIDTH did work, but you were still not happy with the page breaking arrangement? Did the sample code that used CELLWIDTH work??

It sounds to me tlike this may be a question for Tech Support.

cynthia
N/A
Posts: 0

Re: Text wrapping?

sorry for being unclear. I should have said CELLWIDTH did not work. And then I tried truncating the field down to 30 characters and the report still wrapped to the next page. It only happens on some of the data, but I can't tell where it's happening.
I've opened a tech support ticket. Maybe they'll see something obvious I'm missing.
Thanks for the help!
Ask a Question
Discussion stats
  • 5 replies
  • 204 views
  • 0 likes
  • 2 in conversation