How to prevent words getting half (and half of it in next line) in proc report ? ?

Reply
Occasional Contributor
Posts: 18

How to prevent words getting half (and half of it in next line) in proc report ? ?

Hello,

I am creating a proc report and outputting in a PDF file. I facing a problem during the report as some of the observations are long.

Once sentence is longer than cellwidth the remainning words go to next line. The problem is sometimes half of the word goes to next line.

That doesn't look good. If i adjust width for one observation other observation gets same problem as all observation is not having same sentence.

I hope you guys have understood. Ultimately what i want is word has to be ramained whole and whole word should go to next line.

Example:

Column1                               column2        column3

-------------------------------------------------------------------------------------------------------------------------

This is first line. and it is ve     sometext      sometext

ry long line.

Respected Advisor
Posts: 4,654

Re: How to prevent words getting half (and half of it in next line) in proc report ? ?

You can use

define column1 / style=[nobreakspace=on];

and write the cell entry as

"/This is first line./And it is very long line./"

the entry will split at the /.

PG

PG
Occasional Contributor
Posts: 18

Re: How to prevent words getting half (and half of it in next line) in proc report ? ?

HI,

Thanks for the helpful tips but in my observations I do not have "/". Also I have only one sentence some times and it still gives broken word when i use style=[nobreakspace=on].

Respected Advisor
Posts: 4,654

Re: How to prevent words getting half (and half of it in next line) in proc report ? ?

In my experience, which is limited with proc report, long entries only split at space characters with the default style=[nobreakspace=yes]. ?

PG


PG
SAS Super FREQ
Posts: 8,743

Re: How to prevent words getting half (and half of it in next line) in proc report ? ?

Hi,

  According to the doc:

SAS(R) 9.2 Output Delivery System: User's Guide The values for NOBREAKSPACE are either ON (YES) or OFF (NO) and the doc says:

NOBREAKSPACE= ON | OFF

specifies how to handle space characters in cells.

ON does not let SAS break a line at a space character.

OFF lets SAS break a line at a space character if appropriate.

Restriction:The NOBREAKSPACE= attribute is valid in markup family destinations, printer family destinations, and the RTF destination.

  I hardly ever tamper with NOBREAKSPACE. It is my experience that with the default behavior (to break at a space, where possible) is the behavior I want. If you see in the tests below, I don't see a lot of difference between the default and playing with NOBREAKSPACE. So I have gotten into the habit of using ODS ESCAPECHAR for inserting a line break where I want it. My experience is that ODS, especially ODS PDF breaks very nicely for me at a space using the default settings. For most of the obs below, the result is the same whether I use nobreakspace OFF or ON. So I really think that CELLWIDTH should be controlling correctly, especially if you really have spaces in your data value.

  I would suspect something in your data causing words to break oddly. This, to me, indicates a "visit" to Tech Support for help where they look at all of your ACTUAL code and your ACTUAL data and your ACTUAL output and go from there.

cynthia


data longtext;

  length col1 other $150 col2 col3 $20;

  infile datalines dlm=',' dsd;

  input col1 $ col2 $ col3 $;

  other=col1;

return;

datalines;

"This is first line. and it is a very long line.", "sometext", "sometext"

"/This is first line./And it is a very long line./",'PGSTATS','suggest'

"This is first line.^{newline 1}And it is a very long line.",'ESCAPECHAR','suggest1'

"Twas brillig and the slithy toves did gyre and gimble in the wabe","Lewis Carroll", "Jabberwocky"

"antidisestablishmentarianism supercalifragilisticexpealidocious","Mary Poppins","and other"

"notasinglespacenospacesnothingnonospacesabcdefghijklmnopqrstuvwxyz",'no spaces','no spaces'

"veryverylong^{newline 1}word short ^{newline 1} veryveryverylong ^{newline 1} veryveryveryverylongword",'some spaces','some'

;

run;

ods escapechar='^';
ods pdf file='c:\temp\longtext1.pdf';

proc report data=longtext nowd;
  title '1)Take Defaults - Only Changing cellwidth';
  title2 'Do not observe behavior you describe';
  column col1 other col2 col3;
  define col1 / display style(column)={cellwidth=.75in};
  define other / display style(column)={cellwidth=2in};
  define col2 / display;
  define col3 / display;
run;
ods pdf close;

ods pdf file='c:\temp\longtext2.pdf';

proc report data=longtext nowd;
  title '2) NObreakspace changes';
  column col1 col1=c1off other other=othoff;
  define col1 / display style(column)={cellwidth=.75in nobreakspace=yes} 'NBSP=YES';
  define c1off / display style(column)={cellwidth=.75in nobreakspace=no} "NBSP=NO";
  define other / display style(column)={cellwidth=2in nobreakspace=yes} "NBSP=YES";
  define othoff / display style(column)={cellwidth=2in nobreakspace=no} "NBSP=NO";
run;
ods pdf close;

Ask a Question
Discussion stats
  • 4 replies
  • 425 views
  • 3 likes
  • 3 in conversation