BookmarkSubscribeRSS Feed
ninemileshigh
Obsidian | Level 7

I am using the following code to produce a scatter matrix. It works fine, except for the labels and legend items, which require sub/superscripts. All I can get is replication of the SAS code within the quotes instead of the required labels. I have highlighted the code in red where I am trying to modify the labels. I am running SAS 9.3.

ODS ESCAPECHAR= '^';

ODS LISTING CLOSE;

ODS HTML FILE= 'N_MATRIX.HTML' PATH= "." STYLE= STYLES.N_MATRIX;

ODS GRAPHICS / IMAGENAME= 'N_MATRIX' IMAGEFMT= GIF ANTIALIASMAX= 34100;

ODS RTF FILE= "&FOLDER.\N_MATRIX.RTF" STYLE= STYLES.N_MATRIX;;

PROC TEMPLATE;

     DEFINE STATGRAPH SCATTERPLOTMATRIX;

        BEGINGRAPH / DESIGNWIDTH=14.2CM DESIGNHEIGHT=16CM ;

           LAYOUT GRIDDED;

              SCATTERPLOTMATRIX

                 SM_VOL STEMP_C /* _NH4_PPM_10 _NO3_PPM_10 _SWC_PCT_10 INT_PAR */ VEG_C SURF_C ECAIR ECRAD  EXT_PAR /

                 GROUP= TREAT NAME= "MATRIX" INSET= (PEARSONPVAL) INSETOPTS=(BACKGROUNDCOLOR= WHITE  AUTOALIGN= AUTO TEXTATTRS=(FAMILY="Arial" SIZE=6pt WEIGHT=BOLD));

                 LEGENDITEM NAME= "FER" / LABEL= "FER";

                 LEGENDITEM NAME= "NH4" / LABEL= "NH^{UNICODE '2084'X}";

                 LEGENDITEM NAME= "NO3" / LABEL= "NO^{UNICODE '2083'X}";

              DISCRETELEGEND "MATRIX" / BACKGROUNDCOLOR= LIGHTGRAY;

           ENDLAYOUT;

        ENDGRAPH;

     END;

RUN;

PROC SGRENDER DATA= AUTO_ALLVAR2 TEMPLATE= SCATTERPLOTMATRIX;

     LABEL /*N2O_uGM2HR= "Flux N^{UNICODE '2082'X}O (^{UNICODE '03BC'X}g m^{UNICODE '3192'X}^{UNICODE '00b2'X} h^{UNICODE '3192'X}^{UNICODE '00b9'X})" */

           EXT_PAR= "PAR mmol m^{UNICODE '3192'X}^{UNICODE '00b2'X} s^{UNICODE '3192'X}^{UNICODE '00b9'X}"

           TREAT= "Nitrogen treatment"

           ECRAD= "Rad W m^{UNICODE '3192'X}^{UNICODE '00b2'X}"

           ECAIR= "Air temp ^{UNICODE '2070'X}C"

           SM_VOL= "Soil moisture m m^{UNICODE '3192'X}^{UNICODE '00b3'X}"

           STEMP_C= "Soil temp ^{UNICODE '2070'X}C"

           VEG_C = "Canopy temp ^{UNICODE '2070'X}C"

           SURF_C= "Surface temp ^{UNICODE '2070'X}C"

           NH4= "NH^{UNICODE '2084'X}"

           NO3= "NO^{UNICODE '2083'X}";

RUN;

ODS RTF CLOSE;

ODS LISTING;

6 REPLIES 6
djrisks
Barite | Level 11

Using hexadecimal may be the way you want to go because if you use the following statement within your Proc SGRENDER statemetn, you can get a superscript of 3 in your label.

label EXT_PAR = Test'b3'x;

ninemileshigh
Obsidian | Level 7

Thanks, this has helped me get my superscripts. I have spent so long trying to get this right! I am still not able to figure out the subscripts. I cannot find hex codes for all the characters I require (it's scientific notation, so I need subscript numbers and superscript minus sign).

Jay54
Meteorite | Level 14

Yes, this can get a bit confusing, so here is way to determine if {SUP} and {SUB} are supported. 

{SUP} and {SUB} ARE supported when the text string is rendered by a TITLE, FOOTNOTE, ENTRY or ANNOTATION statement.  These statements do not go through the "data" based graph rendering system and render the strings directly using Java.

{SUP} and {SUB} are NOT supported when the string is part of the data based graph itself, such as the axis items  (Axis Label or Axis Tick Values), Data Label, Curve Labels and Legend Labels (including the Legend Item).  One exception is if you make a LEGEND ITEM of type=TEXT.  In this case, the text string assigned to the TEXT= option can support {SUP} and {SUB}.

You can us the built-in Unicode superscript or subscript glyphs in all of the above.  But the benefit of {SUB} is you can make any Unicode character or string into a subscript or superscript.

ninemileshigh
Obsidian | Level 7

Thanks for the advice. I find it strange that I can successfully use hex codes for superscripts in SGrender  but only for certain characters. The other odd thing is that when I define an axis label in proc format it is quite happy with unicode for superscript numbers, but not for - symbol and unicode subscripts don't work either. It's the same for SUP and SUB (SUP works but not SUB). I have decided to work around it with formatted text in my legend when I import the figure to MS Word.

djrisks
Barite | Level 11

That's fine. I understand, I've been trying to also obtain subscripts and I haven't succeeded yet. At the moment, the only solution I can think off is including the required labels within the footnote.

ninemileshigh
Obsidian | Level 7

Thanks- I have come to pretty much the same conclusion myself. I've tried all sorts but had no success with the subscripts.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 3587 views
  • 5 likes
  • 3 in conversation