The SAS Output Delivery System and reporting techniques

Assigning a color to a unicode symbol in ODS Text string

Accepted Solution Solved
Reply
Regular Contributor
Posts: 150
Accepted Solution

Assigning a color to a unicode symbol in ODS Text string

Hi,

 

Am trying to assign a specific color to the 2symbols per below:

 

ods escapechar='^';

...

ods text='^{unicode 2588}^{unicode 2588} is a red box';

 

I've tried adding cominbinations of inline styles every way I can and struck out.  Example:

ods text='^s={color=red}^{unicode 2588}^{unicode 2588} is a red box';

does not work.  

 

Anyone know the magic combination? 

 

Thanks!

 

--Ben


Accepted Solutions
Solution
‎01-17-2017 08:11 PM
SAS Super FREQ
Posts: 8,642

Re: Assigning a color to a unicode symbol in ODS Text string

Hi, I have an example of using Unicode 2588 to "fake" a bar chart and another example of using Unixcode 250A to "fake" a dynamically sized box. However, both of those were accomplished in cells in PROC REPORT. You did not specify your destination, so it's hard to predict what will work in every destination, but this worked for me in HTML and should work for RTF and PDF.
 


ods escapechar='^';
 

ods text='1 ^{style[color=red font_face="Thorndale AMT" fontsize=16pt] ^{unicode 2588} ^{style[font_size=12pt font_weight=bold] is a red box}}';
ods text= ' ';
ods text='2 ^{style[color=red font_face="Thorndale AMT" fontsize=16pt] ^{unicode 2588}} ^{style[font_size=12pt font_weight=bold] is a} ^{style[color=red]red} box ';

 Think of your UNICODE function as being the text string you want to have treated differently (appear in red). So that string, which happens to be a UNICODE function needs to be surrounded by a STYLE function (also invoked with ESCAPECHAR).

 

  The way the style function works is this -- assuming ESCAPECHAR is ^:

'^{style[attr=val attr1=val1]text string}'

  I know, the color coding is garish, but, I hope, makes the point that the STYLE function starts and stops with curly braces and the attribute/value pairs are enclosed in square brackets. After the ending square bracket, you have the text string (whatever it is) and then you have the closng curly brace to end the beginning curly brace (what is shown in red. Where I have text string in the example above, is where you put your ^{UNICODE 2588}, as shown in my code.

 

  Here's what it looks like in HTML output:

ods_escapechar_text_box.png
cynthia

View solution in original post


All Replies
Solution
‎01-17-2017 08:11 PM
SAS Super FREQ
Posts: 8,642

Re: Assigning a color to a unicode symbol in ODS Text string

Hi, I have an example of using Unicode 2588 to "fake" a bar chart and another example of using Unixcode 250A to "fake" a dynamically sized box. However, both of those were accomplished in cells in PROC REPORT. You did not specify your destination, so it's hard to predict what will work in every destination, but this worked for me in HTML and should work for RTF and PDF.
 


ods escapechar='^';
 

ods text='1 ^{style[color=red font_face="Thorndale AMT" fontsize=16pt] ^{unicode 2588} ^{style[font_size=12pt font_weight=bold] is a red box}}';
ods text= ' ';
ods text='2 ^{style[color=red font_face="Thorndale AMT" fontsize=16pt] ^{unicode 2588}} ^{style[font_size=12pt font_weight=bold] is a} ^{style[color=red]red} box ';

 Think of your UNICODE function as being the text string you want to have treated differently (appear in red). So that string, which happens to be a UNICODE function needs to be surrounded by a STYLE function (also invoked with ESCAPECHAR).

 

  The way the style function works is this -- assuming ESCAPECHAR is ^:

'^{style[attr=val attr1=val1]text string}'

  I know, the color coding is garish, but, I hope, makes the point that the STYLE function starts and stops with curly braces and the attribute/value pairs are enclosed in square brackets. After the ending square bracket, you have the text string (whatever it is) and then you have the closng curly brace to end the beginning curly brace (what is shown in red. Where I have text string in the example above, is where you put your ^{UNICODE 2588}, as shown in my code.

 

  Here's what it looks like in HTML output:

ods_escapechar_text_box.png
cynthia

Regular Contributor
Posts: 150

Re: Assigning a color to a unicode symbol in ODS Text string

Hi Cynthia,

 

LOL...  that was the one combination I hadn't tried.  Just wasn't creative enough.  Thank you so much!

 

The target in this case is about 5000 pdf files.

 

 

 

--Ben

Post a Question
Discussion Stats
  • 2 replies
  • 183 views
  • 0 likes
  • 2 in conversation