BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ken_oy
Fluorite | Level 6

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
1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

2 REPLIES 2
Cynthia_sas
SAS Super FREQ

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;

Ken_oy
Fluorite | Level 6

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};

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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