BookmarkSubscribeRSS Feed
JeffNCSU
Calcite | Level 5

Using Proc sgplot, and having some numbers needed to be subscript.

Tried to use

ODS escpechar='^";   and move options, but they did not work.

Data test;

input x y;

datalines;

1 2

3 6

7 10

8 19

;

run;

proc sgplot data=test;

   scatter x=x y=y;

  xaxis label="H2O";

yaxis label ="(NH3)2SO4";

run;

5 REPLIES 5
JeffNCSU
Calcite | Level 5

Thanks, I tried the following code, the output was not correct.

Data test;

input x y;

datalines;

1 2

3 6

7 10

8 19

;

run;

ODS escapechar='^';

proc sgplot data=test;

   scatter x=x y=y;

  xaxis label="H^{unicode '2082'x}O";

yaxis label ="(NH^{unicode '2083'x})^{unicode '2082'x}SO^{unicode '2084'x}";

run;

Results Preference.pngoutput.png

DanH_sas
SAS Super FREQ

The reason you're seeing the boxes is that the font you're using does not support enough of the Unicode specification to include all of the superscipt and subscript values. The example referenced by Art contained a little piece of code similar to the one below:


proc template;                                                                                                                         
   define style style.unifonts;                                                                                                               
   parent=Styles.Listing; /* or your favorite style */  
   style Graphfonts from GraphFonts /                                                                                                                  
   'GraphValueFont' = ("Monotype San WT  J",12pt)                                                                                            
      'GraphLabelFont' = ("Monotype San WT J",14pt)
      'GraphDataFont' = ("Monotype San WT J",12pt)
      'GraphTitleFont' = ("Monotype San WT J",12pt);                                                                                           
   end;                   
run;

If you set this style as your ODS style, then you're boxes will be filled! 🙂

ods listing style=unifonts;

data test;

input x y;

datalines;

1 2

3 6

7 10

8 19

;

run;

ods escapechar='^';

proc sgplot data=test;

   scatter x=x y=y;

  xaxis label="H^{unicode '2082'x}O";

yaxis label ="(NH^{unicode '2083'x})^{unicode '2082'x}SO^{unicode '2084'x}";

run;

Hope this helps,

Dan

JeffNCSU
Calcite | Level 5

Thanks Dan!

the HTML Type output was not correct.

The PNG Type output was correct.

Normally I copy the figure from HTML  Type, because it looks very neat.

html.pngPng.png

art297
Opal | Level 21

Seemed to work ok for me.  Did I miss something?  The code I used was:

Data test;

  input x y;

  datalines;

1 2

3 6

7 10

8 19

;

proc template;                                                                                                                         

   define style unifonts;                                                                                                               

   parent=Styles.Default;  

   style Graphfonts from GraphFonts /                                                                                                                  

      'GraphValueFont' = ("Monotype San WT J",12pt)                                                                                            

      'GraphLabelFont' = ("Monotype San WT J",14pt)

      'GraphDataFont' = ("Monotype San WT J",12pt)

      'GraphTitleFont' = ("Monotype San WT J",12pt);                                                                                           

   end;                   

run; 

ods escapechar='^';

ods listing close;

ods html file='subsuper.html' path='c:\art' style=unifonts;

ods graphics / reset width=600px height=400px imagename='SubSuper' imagefmt=gif;

title 'Using Subscripts and Superscripts';

proc sgplot data=test;

   scatter x=x y=y;

   xaxis label="H^{unicode '2082'x}O";

   yaxis label ="(NH^{unicode '2083'x})^{unicode '2082'x}SO^{unicode '2084'x}";

run;

ods html close;

ods listing;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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