<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PROC REPORT - Highlighting a few key words, and not others, within a text string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Highlighting-a-few-key-words-and-not-others-within-a/m-p/973688#M377735</link>
    <description>&lt;P&gt;I have modified the data using a DATA step to add in-line formatting.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data w_1_s_3_tmp;
length summary $500;
set w_1_s_3_tmp;
format summary $500.;
informat summary $500.;
if index(strip(summary),'Mostly sunny') gt 0 then do;
 summary=tranwrd(summary,'Mostly sunny','^S={background=yellow} Mostly sunny ^S={}');
end;
if index(summary,'shower') gt 0 then do;
 summary=tranwrd(summary,'shower','^S={foreground=purple font_weight=bold} shower ^S={}');
end;
run;

ods escapechar='^';
ods listing close;
ods html5 path='c:\temp' file='test.html';

proc report data = W_1_s_3_TMP NOHEADER ;
Column 	Summary	;
define	Summary 	/display style(column)=[font_size=4.0 just=l cellwidth=6in	/*cellheight=0.25in*/
borderrightcolor=white	borderleftcolor=white bordertopcolor=white borderbottomcolor=white 
backgroundcolor=white]	 	; 
run	;

ods _all_ close;
ods listing;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have attached a picture of the output I get.&lt;/P&gt;</description>
    <pubDate>Fri, 29 Aug 2025 15:38:54 GMT</pubDate>
    <dc:creator>Kathryn_SAS</dc:creator>
    <dc:date>2025-08-29T15:38:54Z</dc:date>
    <item>
      <title>PROC REPORT - Highlighting a few key words, and not others, within a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Highlighting-a-few-key-words-and-not-others-within-a/m-p/973669#M377733</link>
      <description>&lt;P&gt;Hello SAS Friends,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using either SAS ver 9.4 or SAS Studio....&lt;CODE class=""&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Is it possible to add highlights and font colors to a few key words within a text string, and not others within the same string?&amp;nbsp;&lt;/P&gt;&lt;P&gt;The entire text string resides within a single variable column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example in this sentence would like to highlight "&lt;STRONG&gt;Mostly sunny&lt;/STRONG&gt;" in yellow and "&lt;STRONG&gt;shower&lt;/STRONG&gt;" in purple font.&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;&amp;nbsp;&lt;STRONG&gt;Mostly sunny&lt;/STRONG&gt;, with a high near 79. chance of an afternoon &lt;STRONG&gt;shower&lt;/STRONG&gt;, moderate Southwest wind.&lt;/SPAN&gt;" (This comments board wont allow for coloring text, I think, so they're just &lt;STRONG&gt;BOLDED&lt;/STRONG&gt;).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attached is an example of the text output wanted (Want_text)&lt;/P&gt;&lt;P&gt;A sample SAS dataset (w_1_s_3_tmp)&lt;/P&gt;&lt;P&gt;The Proc Report code used for the SAS dataset (W_Tmp)&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc report data = 	W_1_s_3_TMP			/*headline*/  NOHEADER	style(header)=[font_size=0]  ;
Column 	Summary	;
define	Summary 	/	style(column)=[font_size=4.0 just=l cellwidth=6in	/*cellheight=0.25in*/
borderrightcolor=white	borderleftcolor=white		bordertopcolor=white	borderbottomcolor=white    backgroundcolor=white]	 	; 
run	;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not been able to find a way of doing this using SAS, and as a work around we've been exporting the Proc Report output as a HTML5 file, and editing by hand.&lt;/P&gt;&lt;P&gt;Thank you for your thoughts on how to do this all within SAS, it would save us allot of time!&lt;/P&gt;&lt;P&gt;R.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Aug 2025 14:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Highlighting-a-few-key-words-and-not-others-within-a/m-p/973669#M377733</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2025-08-29T14:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT - Highlighting a few key words, and not others, within a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Highlighting-a-few-key-words-and-not-others-within-a/m-p/973688#M377735</link>
      <description>&lt;P&gt;I have modified the data using a DATA step to add in-line formatting.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data w_1_s_3_tmp;
length summary $500;
set w_1_s_3_tmp;
format summary $500.;
informat summary $500.;
if index(strip(summary),'Mostly sunny') gt 0 then do;
 summary=tranwrd(summary,'Mostly sunny','^S={background=yellow} Mostly sunny ^S={}');
end;
if index(summary,'shower') gt 0 then do;
 summary=tranwrd(summary,'shower','^S={foreground=purple font_weight=bold} shower ^S={}');
end;
run;

ods escapechar='^';
ods listing close;
ods html5 path='c:\temp' file='test.html';

proc report data = W_1_s_3_TMP NOHEADER ;
Column 	Summary	;
define	Summary 	/display style(column)=[font_size=4.0 just=l cellwidth=6in	/*cellheight=0.25in*/
borderrightcolor=white	borderleftcolor=white bordertopcolor=white borderbottomcolor=white 
backgroundcolor=white]	 	; 
run	;

ods _all_ close;
ods listing;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have attached a picture of the output I get.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Aug 2025 15:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Highlighting-a-few-key-words-and-not-others-within-a/m-p/973688#M377735</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2025-08-29T15:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT - Highlighting a few key words, and not others, within a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Highlighting-a-few-key-words-and-not-others-within-a/m-p/973689#M377736</link>
      <description>&lt;P&gt;Here is the answer for the font color which works great.&amp;nbsp; For Highlight, will just include that from the 'Styles' offering.&amp;nbsp; Thanks:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data W_1_S_3_TMP ;
  set DAT_1.W_1_S_3_TMP;
  length Summ_1 $95 ;
  Summ_1 = tranwrd(Summary,'Sunny','(*ESC*){style [fontweight=extra_bold color=yellow]Sunny}');
  format Summ_1;
run;

proc report data = 	W_1_s_3_TMP			/*headline*/  NOHEADER	style(header)=[font_size=0]  ;
Column 	Summ_1	;
define	Summ_1 	/	style(column)=[font_size=4.0 just=l cellwidth=6in	/*cellheight=0.25in*/
borderrightcolor=white	borderleftcolor=white		bordertopcolor=white	borderbottomcolor=white    backgroundcolor=white]	 	; 
run	;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Aug 2025 15:40:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Highlighting-a-few-key-words-and-not-others-within-a/m-p/973689#M377736</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2025-08-29T15:40:42Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT - Highlighting a few key words, and not others, within a text string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Highlighting-a-few-key-words-and-not-others-within-a/m-p/973690#M377737</link>
      <description>&lt;P&gt;This is great !&amp;nbsp; Thank you Kathryn_SAS !&lt;/P&gt;</description>
      <pubDate>Fri, 29 Aug 2025 15:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-Highlighting-a-few-key-words-and-not-others-within-a/m-p/973690#M377737</guid>
      <dc:creator>rmacarthur</dc:creator>
      <dc:date>2025-08-29T15:42:12Z</dc:date>
    </item>
  </channel>
</rss>

