Data visualization with SAS programming

How to use unicode >= Symbol in SAS/Graph Legend

Accepted Solution Solved
Reply
Occasional Contributor jb3
Occasional Contributor
Posts: 15
Accepted Solution

How to use unicode >= Symbol in SAS/Graph Legend

[ Edited ]

Hi all,

 

I would like to use the unicode symbols for <= and >= in a SAS/Graph legend in SAS 9.4M2 on Windows. The unicode symbols are assigned using proc format. How can I achieve this? I use the code below, and the unicode symbol is not rendered as a symbol but as text.

 

Thanks for your help!

Jonas

 

 

goptions reset=all;

proc format;
	value hp
		low-100 = "'2264'x <= 100" 
		100-150 = "101 - 150"
		150-high= ">= 101"
	;
run;

legend1 label=none;

proc gchart data=sashelp.cars;	
	pie Horsepower / 
		discrete
		value=none 
		slice=outside
		other= 0
		legend=legend1
	;
	format Horsepower hp.;
run;

  


SAS Unicode in Legend.png

Accepted Solutions
Solution
‎04-07-2016 10:58 AM
SAS Employee
Posts: 967

Re: How to use unicode >= Symbol in SAS/Graph Legend

One way to do this in SAS/Graph would be to specify *all* the characters in the legend as their 4-digit unicode number. This is a bit cumbersome, but if you only have one (or a few) graphs, perhaps it's an acceptable work-around(?)

 

proc format;
	value hp
		low-100 = '226400a0003100300030'x
		100-150 = '00300030003100a000ad00a0003100350030'x
		150-high= '226500a0003100300031'x
	;
run;

legend1 label=('Horsepower: ') value=(justify=left font='albany amt/unicode');

proc gchart data=sashelp.cars;	
	pie Horsepower / 
		discrete
		value=none 
		other= 0
		legend=legend1
	;
	format Horsepower hp.;
run;

horsepower.png

View solution in original post


All Replies
Super Contributor
Posts: 408

Re: How to use unicode >= Symbol in SAS/Graph Legend

[ Edited ]

Hi Jonas,

 

Have a look at this blog post: http://blogs.sas.com/content/graphicallyspeaking/2015/07/29/unicode-in-formatted-data-sas-9-40m3/.

 

It does exactly what you're looking for, although it does require SAS 9.4M3! Kudos to Sanjay Matange.

 

Regards, Jan.

Super User
Super User
Posts: 7,401

Re: How to use unicode >= Symbol in SAS/Graph Legend

You will want to a) move to sgplot and gtl, b) check out this blog which has code examples on everything sgplot/gtl related.  Note in this link I have filtered for exactly what you request, but do have a look at the whole blog as there are many examples:

http://blogs.sas.com/content/graphicallyspeaking/?s=unicode

 

 

Occasional Contributor jb3
Occasional Contributor
Posts: 15

Re: How to use unicode >= Symbol in SAS/Graph Legend

Thanks for your answers. Is there really no chance of doing this in SAS/Graph?
Super Contributor
Posts: 408

Re: How to use unicode >= Symbol in SAS/Graph Legend

I have given it a shot but the approach taken by the blog is ODS, and thus limited to ODS graphics. So it won't work from eg. the Bar Chart task in EG.

 

There are examples floating around using hex characters (ALT-codes from the keyboard) in the labels but the results I had with a quick test were inconsistent. But you may want to give that a try.

 

Reg's Jan.

Solution
‎04-07-2016 10:58 AM
SAS Employee
Posts: 967

Re: How to use unicode >= Symbol in SAS/Graph Legend

One way to do this in SAS/Graph would be to specify *all* the characters in the legend as their 4-digit unicode number. This is a bit cumbersome, but if you only have one (or a few) graphs, perhaps it's an acceptable work-around(?)

 

proc format;
	value hp
		low-100 = '226400a0003100300030'x
		100-150 = '00300030003100a000ad00a0003100350030'x
		150-high= '226500a0003100300031'x
	;
run;

legend1 label=('Horsepower: ') value=(justify=left font='albany amt/unicode');

proc gchart data=sashelp.cars;	
	pie Horsepower / 
		discrete
		value=none 
		other= 0
		legend=legend1
	;
	format Horsepower hp.;
run;

horsepower.png

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 636 views
  • 4 likes
  • 4 in conversation