BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gabonzo
Quartz | Level 8

Hi,

I have defined a FORMAT that uses unicode superscripts:

	proc format;
		value agegroupfr 	1="1(*ESC*){super re} fois"
							2="2(*ESC*){super e} fois ou plus"
							3="18–24"
							4="25–34"
							5="35–44"
							6="45–54"
							7="55–64"
							8="65–74"
							9="75+"
							10="Toutes";
	run;


I want to use this format to be used to label values on the y-axes of a butterfly plot. Here is the portion of the code where I define the y-axes:

	 	yaxis reverse
		 	display=(noticks)
		 	valueattrs=(color=gray33 size=10pt family="Arial Unicode MS")
		 	labelposition=top
		 	colorbands=odd colorbandsattrs=(color=grayf3)
		 	label="&aglab."
		 	valuesformat=&agfmt.;
		y2axis reverse
			type=discrete
		 	display=(noticks)
		 	valueattrs=(color=gray33 size=10pt family="Arial Unicode MS")
		 	labelposition=top
		 	label="&aglab."
		 	valuesformat=&agfmt.;


The result is not what I expected:


SGPlot31.png

I have tried several solutions proposed in this forum, but with no effect. What am I doing wrong?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
JeffMeyers
Barite | Level 11

I don't think it can be done normally, so I would suggest looking into annotation which allows all superscripts and Unicode.  Here is a link to SG annotation dataset information: link 

 

The following example I make an annotation dataset and make the normal tick values white so they can't be seen (but still create the graph space for them).  I then use annotation to draw new y-axis tick values with the wanted superscripts.

 

proc format;
    value xx
        80='80(*ESC*){Sup "e"}'
        60='60(*ESC*){Sup "er"}';
run;

data yaxis;
   length function $ 8 label $ 25;
    do i = 60 to 140 by 20;
       function="text"; x1=-5; y1=i; x1space="datapercent";y1space="Datavalue";
      label=strip(put(i,xx.));size=10;textcolor='black';
      output;
    end;
      /* create observation to draw the title */
    do i = 60 to 140 by 20;
       function="text"; x1=105; y1=i; x1space="datapercent";y1space="Datavalue";
      label=strip(put(i,xx.));size=10;textcolor='black';
      output;
    end;
    drop i;
run;

ods graphics / reset;
proc sgplot data=sashelp.class sganno=yaxis;
    scatter x=height y=weight;
    scatter x=height y=weight / y2axis markerattrs=(size=0pt);
    yaxis valueattrs=(color=white) labelposition=top ;
    y2axis valueattrs=(color=white) display=(nolabel)  ;
run;

image.png

 

View solution in original post

7 REPLIES 7
Reeza
Super User

Have you tried this suggestion: https://communities.sas.com/t5/Graphics-Programming/Superscript-in-axis-label-SGPLOT/td-p/529656

I'm also assuming you have the ODS ESCAPECHAR set somewhere else since you haven't shown your full code.

I'll move your post to the graphics forum, but it would probably help if you could include some data and the full code so someone can replicate your issue. Or make a simpler example using sashelp.class if necessary.

 

FYI - it seems SUPER/SUB are not supported in AXIS statements but you can use the Unicode characters instead if it's available.

gabonzo
Quartz | Level 8

I have tried setting 

ods escapechar="^";  

And redefining the format as

	proc format;
		value agegroupfr 	1="1^{super re} fois"
							2="2^{super e} fois ou plus"
							3="18–24"
							4="25–34"
							5="35–44"
							6="45–54"
							7="55–64"
							8="65–74"
							9="75+"
							10="Toutes";
	run;

No superscripts there either.

Reeza
Super User
SUPER and SUB do not work in AXIS statements. You need to use the codes as indicated in the post I've linked to, your code is still using SUPER/SUB.

gabonzo
Quartz | Level 8

Thank you for your help, but nope:

	proc format;
		value agegroupfr 	1="1^{unicode '1d49'x} fois"
							2="2(*ESC*){unicode '1d49'x} fois ou plus"
							3="18–24"
							4="25–34"
							5="35–44"
							6="45–54"
							7="55–64"
							8="65–74"
							9="75+"
							10="Toutes";
	run;

Result:

SGPlot91.png

gabonzo
Quartz | Level 8

Simplified example so anybody can try:

Creating the unicode format:

 

proc format;
	value unitest 	0="^{unicode '0024'x}"
				1="^{unicode '0040'x}";
run;

 

 

Creating the dataset:

 

data have;
	x=0;
	y=0;
	output;
	x=1;
	y=1;
	output;
	format y unitest.;
run;

proc print data=have;
run;

 

 

Looks good so far:

Obs x y
1 0 $
2 1 @

 

 

Now, let's try to plot it:

ods escapechar="^";  
proc sgplot data=have;
	scatter x=x y=y;
	yaxis display=(noticks) valueattrs=GraphTextUnicode;
run;

aaand....

SGPlot95.png

*sad_trombone.mp3*

JeffMeyers
Barite | Level 11

I don't think it can be done normally, so I would suggest looking into annotation which allows all superscripts and Unicode.  Here is a link to SG annotation dataset information: link 

 

The following example I make an annotation dataset and make the normal tick values white so they can't be seen (but still create the graph space for them).  I then use annotation to draw new y-axis tick values with the wanted superscripts.

 

proc format;
    value xx
        80='80(*ESC*){Sup "e"}'
        60='60(*ESC*){Sup "er"}';
run;

data yaxis;
   length function $ 8 label $ 25;
    do i = 60 to 140 by 20;
       function="text"; x1=-5; y1=i; x1space="datapercent";y1space="Datavalue";
      label=strip(put(i,xx.));size=10;textcolor='black';
      output;
    end;
      /* create observation to draw the title */
    do i = 60 to 140 by 20;
       function="text"; x1=105; y1=i; x1space="datapercent";y1space="Datavalue";
      label=strip(put(i,xx.));size=10;textcolor='black';
      output;
    end;
    drop i;
run;

ods graphics / reset;
proc sgplot data=sashelp.class sganno=yaxis;
    scatter x=height y=weight;
    scatter x=height y=weight / y2axis markerattrs=(size=0pt);
    yaxis valueattrs=(color=white) labelposition=top ;
    y2axis valueattrs=(color=white) display=(nolabel)  ;
run;

image.png

 

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
  • 7 replies
  • 2064 views
  • 6 likes
  • 3 in conversation