BookmarkSubscribeRSS Feed
SAS_jrnew
Calcite | Level 5

Hi There,

I am trying to display tilde character in titles for png files. Tilde character is not resolving. I am doing the below.

title "The code has  {*ESC*}{unicode '223c'x}34000 characters";

I also tried creating global variable and didn't work like below.

%global x ;

data _null_;

call symput('x', byte(126));

run;

title "The code has  &til.34000 characters";

11 REPLIES 11
RichardDeVen
Barite | Level 11

Read over the documentation carefully.

 

The escape sequence should use parenthesis

 

(*ESC*)

The inline formatting unicode function will accept a variety of value specifications, all these work (tested in SAS 9.4 TS6)

ods rtf file='sample.rtf';

proc print data=sashelp.class;
  title1 h=12pt "The code has (*ESC*){unicode '223C'x}34,000 characters";
  title2 h=12pt "The code has (*ESC*){unicode 223Cx}34,000 characters";
  title3 h=12pt "The code has (*ESC*){unicode 223C}34,000 characters";
run;

ods rtf close;

RichardADeVenezia_0-1606484090993.png

 

SAS_jrnew
Calcite | Level 5

Hi There,

Thanks. Can you please test it in png files ? RTF seems ok ? png is the problem.?

 

 

ballardw
Super User

@SAS_jrnew wrote:

Hi There,

Thanks. Can you please test it in png files ? RTF seems ok ? png is the problem.?

 

 


Provide data an code that generates the PNG and you may get a better answer.

RichardDeVen
Barite | Level 11

Unicode by number appears to be broken in titles.

Unicode by 'name' works.

 

The discrepancy would appear to be a bug in the SG system. (unicode by number might work for certain fonts, or maybe not.)

 

ods escapechar = '^';

ods html file='sample.html';

proc sgplot data=sashelp.class;
  title1 j=l "In SGPLOT";
  title2 j=l h=14pt "Unicode tilde by name (*ESC*){unicode tilde} works";
  title3 j=l h=14pt "Unicode tilde by number (*ESC*){unicode '223C'x} is broken in title footnote";

  footnote1 j=l h=14pt "Unicode tilde by name (*ESC*){unicode tilde} works";
  footnote2 j=l h=14pt "Unicode tilde by number (*ESC*){unicode '223C'x} is broken in title footnote";

  footnote4 j=l h=14pt "Unicode tilde by number ^{unicode '223C'x} is broken in title footnote";

  vbar sex ;
run;

ods html close;

RichardADeVenezia_0-1606489207720.png

 

 

Ksharp
Super User

Very interesting. %sysfunc(byte(126)) is working.

 

x.pngods escapechar = '^';
ods text="x (*ESC*){unicode '223C'x} xx  %sysfunc(unicode(\u223C))";
proc sgplot data=sashelp.class;
  title1 j=l "In SGPLOT";
  title2 j=l h=14pt "Unicode tilde by name %sysfunc(byte(126)) wwwworks";
  title3 j=l h=14pt "Unicode tilde by number ∼ is broken in title footnote";

  footnote4 j=l h=14pt "Unicode tilde by number %sysfunc(byte(126)) is broken in title footnote";

  vbar sex ;
run;
ChrisNZ
Tourmaline | Level 20

The implementation of Unicode in SAS outputs is messy at best.

 

Plus what used to work doesn't work anymore: See the format in https://communities.sas.com/t5/Graphics-Programming/Unicode-for-lables-of-panels-in-sgpanel/m-p/3328... which no longer works .

 

A major cleanup, simplification and standardisation is long overdue, so one syntax can be used anywhere and for any destination. Unless that's already the case and I missed something?

 

 

 

ChrisNZ
Tourmaline | Level 20

@BeverlyBrown @AnnaBrown Maybe another idea for a pinned topic?

How to: Display Unicode values in reports (labels, titles, formats, text, graphs, email, etc), for various destinations and using various procedures. Ideally, a unique syntax would work regardless of the programming context.

Ksharp
Super User

Yes. I doubt it is FONT problem for proc sgplot  . @GraphGuy  might have a good idea.

ChrisHemedinger
Community Manager

For those testing this, make sure you add gtitle/gfootnote to your ODS statement so that the title/footnote appears as part of the graph image, not in the ODS document.  Example using SAS Enterprise Guide:

 

ods escapechar = '^';
ods html5 (id=eghtml) gtitle gfootnote;
proc sgplot data=sashelp.class;
  title1 j=l "In SGPLOT";
  title2 j=l h=14pt "Unicode tilde by name ^{unicode tilde} works";
  title3 j=l h=14pt "Unicode tilde by number ^{unicode '223C'x} is broken in title footnote";

  footnote1 j=l h=14pt "Unicode tilde by name ^{unicode tilde} works";
  footnote2 j=l h=14pt "Unicode tilde by number ^{unicode '223C'x} is broken in title footnote";

  footnote4 j=l h=14pt "Unicode tilde by number ^{unicode '223C'x} is broken in title footnote";

  vbar sex ;
run;

@DanH_sas shares info on this topic quite often, and might be able to clarify what you're seeing and best practice.

Check out SAS Innovate on-demand content! Watch the main stage sessions, keynotes, and over 20 technical breakout sessions!
DanH_sas
SAS Super FREQ

The keys here involve the font used in the title and the Unicode value used for tilde. Once you get into the 2000's of the Unicode table, the glyph support in the font can be spotty, depending on the font you use. In Chris' case, he referenced tilde two ways. The first way (^{unicode tilde}) cause us to look up tilde in our table, which uses the Unicode value '0303'. This Unicode value probably exists in all Unicode fonts. However, the second reference (^{unicode '223c'x}) explicitly references a 2000-level code, which the default font in this ODS style does not support.

 

With all of that said, you have three choices:

  1. Use the literal '~' in your title
  2. Use ^{unicode tilde} of ^{unicode '0303'x} with no font change
  3. Use ^{unicode '223c'x} while also setting f="Arial Unicode MS" on the TITLE statement

Hope this helps!

Dan

Tom
Super User Tom
Super User

Why are you jumping through hoops to use a character that is part of the 7-bit ASCII codes?

Are you running on an IBM mainframe that uses EBCDIC characters?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 11 replies
  • 1476 views
  • 4 likes
  • 8 in conversation