- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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";
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi There,
Thanks. Can you please test it in png files ? RTF seems ok ? png is the problem.?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Very interesting. %sysfunc(byte(126)) is working.
ods 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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes. I doubt it is FONT problem for proc sgplot . @GraphGuy might have a good idea.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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:
- Use the literal '~' in your title
- Use ^{unicode tilde} of ^{unicode '0303'x} with no font change
- Use ^{unicode '223c'x} while also setting f="Arial Unicode MS" on the TITLE statement
Hope this helps!
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?