BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
5 REPLIES 5
Cynthia_sas
SAS Super FREQ
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]
deleted_user
Not applicable
Thanks Cynthia. I'll give CELLWIDTH a shot and let you know.
deleted_user
Not applicable
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.
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
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!

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