The SAS Output Delivery System and reporting techniques

splitted words in ODS pdf output

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 128
Accepted Solution

splitted words in ODS pdf output

sas questions.png

Please see attached picture. In the "Question" Column, words was splitted to the next line.

How to fix this?

Thanks!


sas questions.png

Accepted Solutions
Solution
‎02-19-2013 06:58 PM
SAS Super FREQ
Posts: 8,868

Re: splitted words in ODS pdf output

Hi:

  I don't observe that behavior when I use PROC REPORT (see code below that produced the attached screenshots). It was my understanding the ODS PDF (and all of ODS) tried to do wrapping at a space in a line as the preferred place to wrap a line and would only split a word as you show if there were no other possible alternative. I created 3 different outputs and none of my long text split at an odd location.

  My guess is that there's something about your data or the procedure you're using that is splitting the text string at an odd location. I show the use of ODS ESCAPECHAR in my code, just to show how to insert a newline/line feed if you want one (in the ANSWER variable), but as you see, I did not need to do that for the QUESTION variable and there were not issues.

  Someone will have to look more closely at your data and your code to see what's up. Seeing a picture of the output isn't going to help you solve this problem. The folks best qualified to help with this are SAS Tech Support. They can look at all your code and your data and help you come to the best resolution.

cynthia

data testit;
  length question $400 answer $200;
  order = 1;
  question = "4b. Do you plan to retain any free "||
             "(non-cost recovered services available "||
             "to all PIs? Such as: "||
             "-Admin support (questionnaires, history, education, etc)";
  answer =  "Answer, N(%)^{newline 1}Yes 34^{newline 1}No 54^{newline 1}Don't Know 11^{newline 1}Missing 12^{newline 1}Total xxx";
  output;
   
  order = 2;
  question = "4b. Do you plan to retain any free "||
             "(non-cost recovered services available "||
             "to all PIs? Such as: "||
             "-Phlebotomy";
  answer =  "Answer, N(%)^{newline 1}Yes 66^{newline 1}No 55^{newline 1}Don't Know 44^{newline 1}Missing 33^{newline 1}Total yyy";
  output;
   
  order=3;
  question = "Twas brillig and the slithy toves "||
             "did gyre and gimble in the wabe. "||
             "All mimsy were the borogroves "||
             "and the momeraths outgrabe. "||
             "Beware the Jabberwock, my son!"||
             "The jaws that bite, the claws that snatch!"||
             "Beware the Jubjub bird and shun "||
             "the frumious Bandersnatch!";
  answer =  "Answer, N(%)^{newline 1}Yes 88^{newline 1}No 99^{newline 1}Don't Know 77^{newline 1}Missing 55^{newline 1}Total zzz";
  output;
run;

ods escapechar='^';
ods pdf file='c:\temp\testit.pdf' style=journal notoc;
proc report data=testit nowd;
  title '1) default column width for both variables';
  column order question answer;
  define order / order noprint;
  define question / 'Question';
  define answer / 'Response';
run;
 
proc report data=testit nowd;
  title '2) small column width for question, none specified for answer';
  column order question answer;
  define order / order noprint;
  define question / 'Question'
         style(column)={cellwidth=1.5in};
  define answer / 'Response';
run;
  
proc report data=testit nowd;
  title '3) big column width for question, smaller for answer';
  column order question answer;
  define order / order noprint;
  define question / 'Question'
         style(column)={cellwidth=3in};
  define answer / 'Response'
         style(column)={cellwidth=2in};
run;
ods pdf close;

View solution in original post


All Replies
Solution
‎02-19-2013 06:58 PM
SAS Super FREQ
Posts: 8,868

Re: splitted words in ODS pdf output

Hi:

  I don't observe that behavior when I use PROC REPORT (see code below that produced the attached screenshots). It was my understanding the ODS PDF (and all of ODS) tried to do wrapping at a space in a line as the preferred place to wrap a line and would only split a word as you show if there were no other possible alternative. I created 3 different outputs and none of my long text split at an odd location.

  My guess is that there's something about your data or the procedure you're using that is splitting the text string at an odd location. I show the use of ODS ESCAPECHAR in my code, just to show how to insert a newline/line feed if you want one (in the ANSWER variable), but as you see, I did not need to do that for the QUESTION variable and there were not issues.

  Someone will have to look more closely at your data and your code to see what's up. Seeing a picture of the output isn't going to help you solve this problem. The folks best qualified to help with this are SAS Tech Support. They can look at all your code and your data and help you come to the best resolution.

cynthia

data testit;
  length question $400 answer $200;
  order = 1;
  question = "4b. Do you plan to retain any free "||
             "(non-cost recovered services available "||
             "to all PIs? Such as: "||
             "-Admin support (questionnaires, history, education, etc)";
  answer =  "Answer, N(%)^{newline 1}Yes 34^{newline 1}No 54^{newline 1}Don't Know 11^{newline 1}Missing 12^{newline 1}Total xxx";
  output;
   
  order = 2;
  question = "4b. Do you plan to retain any free "||
             "(non-cost recovered services available "||
             "to all PIs? Such as: "||
             "-Phlebotomy";
  answer =  "Answer, N(%)^{newline 1}Yes 66^{newline 1}No 55^{newline 1}Don't Know 44^{newline 1}Missing 33^{newline 1}Total yyy";
  output;
   
  order=3;
  question = "Twas brillig and the slithy toves "||
             "did gyre and gimble in the wabe. "||
             "All mimsy were the borogroves "||
             "and the momeraths outgrabe. "||
             "Beware the Jabberwock, my son!"||
             "The jaws that bite, the claws that snatch!"||
             "Beware the Jubjub bird and shun "||
             "the frumious Bandersnatch!";
  answer =  "Answer, N(%)^{newline 1}Yes 88^{newline 1}No 99^{newline 1}Don't Know 77^{newline 1}Missing 55^{newline 1}Total zzz";
  output;
run;

ods escapechar='^';
ods pdf file='c:\temp\testit.pdf' style=journal notoc;
proc report data=testit nowd;
  title '1) default column width for both variables';
  column order question answer;
  define order / order noprint;
  define question / 'Question';
  define answer / 'Response';
run;
 
proc report data=testit nowd;
  title '2) small column width for question, none specified for answer';
  column order question answer;
  define order / order noprint;
  define question / 'Question'
         style(column)={cellwidth=1.5in};
  define answer / 'Response';
run;
  
proc report data=testit nowd;
  title '3) big column width for question, smaller for answer';
  column order question answer;
  define order / order noprint;
  define question / 'Question'
         style(column)={cellwidth=3in};
  define answer / 'Response'
         style(column)={cellwidth=2in};
run;
ods pdf close;

Frequent Contributor
Posts: 128

Re: splitted words in ODS pdf output

Posted in reply to Cynthia_sas

Cythia, thank you so much for your work!

I read your code carefully, and found out I copy/paste an unnecessary command "asis=on" to my ODS coding.

I made the following change in PROC REPORT and my problem solved:

from:

define Variablename  /display "Yes"  STYLE(COLUMN)={asis=on  PROTECTSPECIALCHARS=off cellwidth=0.91 in just=c};

to:

define Variablename  /display "Yes"  STYLE(COLUMN)={ PROTECTSPECIALCHARS=off cellwidth=0.91 in just=c};
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 265 views
  • 0 likes
  • 2 in conversation