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

Hi - How can I style only one word in a paragraph within PROC ODSTEXT, e.g. how would I make bold just the word here in the following code snippet?

 

ods html close;
options nodate;
title 'Using PROC ODSTEXT';
footnote 'The ODS Destination for PDF';
ods pdf file="temp.pdf";
proc odstext;
   p 'I want to style just one word; HERE';
   p 'You can also format your text.' / style=[color=red fontsize=25pt];
   
run;

ods _all_ close;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  ODS ESCAPECHAR to the rescue! When you want to change the style of one word in a cell or text string, then you use a feature called "in-line formatting" using ODS ESCAPECHAR. Basically, you declare a character to get ODS attention and then you specify your style string in curly braces with the style attributes you are changing in square brackets, as shown here:

ods pdf file='c:\temp\use_bold.pdf' ;
    
ods escapechar='^';
options nodate;
title 'Using PROC ODSTEXT';
footnote 'The ODS Destination for PDF';
proc odstext;
   p 'I want to style just one word; ^{style[color=purple fontweight=bold fontsize=25pt]HERE}^{newline 2}';
   p 'You can ^{style[textdecoration=underline]also} format your text.' / style=[color=red fontsize=25pt];
run;

ods _all_ close;

Partial PDF results:

 

escapechar.png

 

  There have been a LOT of postings -- search on ESCAPECHAR or on in-line formatting.

 

cynthia

View solution in original post

4 REPLIES 4
Cynthia_sas
SAS Super FREQ

Hi:

  ODS ESCAPECHAR to the rescue! When you want to change the style of one word in a cell or text string, then you use a feature called "in-line formatting" using ODS ESCAPECHAR. Basically, you declare a character to get ODS attention and then you specify your style string in curly braces with the style attributes you are changing in square brackets, as shown here:

ods pdf file='c:\temp\use_bold.pdf' ;
    
ods escapechar='^';
options nodate;
title 'Using PROC ODSTEXT';
footnote 'The ODS Destination for PDF';
proc odstext;
   p 'I want to style just one word; ^{style[color=purple fontweight=bold fontsize=25pt]HERE}^{newline 2}';
   p 'You can ^{style[textdecoration=underline]also} format your text.' / style=[color=red fontsize=25pt];
run;

ods _all_ close;

Partial PDF results:

 

escapechar.png

 

  There have been a LOT of postings -- search on ESCAPECHAR or on in-line formatting.

 

cynthia

mduarte
Quartz | Level 8
Great - worked perfectly! Thank-you also for the "search terms" ..
Dick_Pickett
Fluorite | Level 6

I'm trying to highlight a sentence without success. Is this even possible in PROC ODSTEXT

   ODS PDF                                                             FILE="xxx.pdf"
   STYLE        =styles.minimal

   PDFTOC       =2
   AUTHOR       ='RTI International'
   ANCHOR       ='SNFRM_REPORT'
   BOOKMARKLIST =none
   BOOKMARKGEN  =NO
   COMPRESS     =9
   COLOR        =FULL
   SUBJECT      ="Skilled Nursing Facility Quality Measure"
   KEYWORDS     ="Skilled Nursing Facility 30-Day All-Cause Readmission Measure (SNFRM)"
   TITLE        ="The Skilled Nursing Facility Value-Based Purchasing Confidential Feedback Quarterly Report";
   ;

   ODS ESCAPECHAR='^';
   FOOTNOTE2 j=center color=black font="Times" height=11pt "1";
      ODS PDF STARTPAGE=NO;
    /* ----------------------------------------------------------------- */
   ODS PROCLABEL "Opening";
    PROC ODSTEXT;
      cellstyle 1 as {font_size=11pt font_weight=medium  just=l font_face=Times};
      p "Below you will find the layout of this report that will be furnished to you quarterly via the Nursing Home Compare Confidential WEB Portal, beginning October, 2016.  ^S={backgroundcolor=yellow font_size=11pt font_weight=bold fontstyle=italic just=l font_face=Times}This document does not include individual SNF performance at this time, but rather is intended to inform you of the SNF VBP measure and the data source used to calculate measure performance.";

Richard F. Pickett, Research Systems Programmer/Analyst
Payment Data Analysis (PDA)
Community Health & Implementation Research Program(CHIRP)
Improving the Human Condition(ITCH)
Social, Statistical & Environmental Sciences(SSES)
RTI International
3040 Cornwallis Road
322 Building 9
Research Triangle Park, NC 27709-2194
Phone: 919.316.3798
Fax: 919.485.5589
mailto:rpickett@rti.org

turning knowledge into practice
Cynthia_sas
SAS Super FREQ

Hi:

  My memory is that ODS PDF can only have 1 color for the background in a cell, so do not think your backgroundcolor=yellow is going to work. You can however italicize, bold and change the size and foreground color for just part of the text within 1 cell as shown below.

Cynthia_sas_0-1698600976605.png

  I did simplify your code a bit and I changed from the original style ODS ESCAPECHAR to the most current (SAS 9.2) "ESCAPECHAR function" format for using ODS ESCAPECHAR. Everything except backgroundcolor worked for me. I had to doctor my screen shot and make the full text of the paragraph smaller, so it would fit in the screen shot.

  If you really need the background color for your sentence to be yellow, I don't think you can do that with PDF.

Cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 4 replies
  • 6642 views
  • 5 likes
  • 3 in conversation