首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >[SAS]绘图如何添加上下标

[SAS]绘图如何添加上下标

作者头像
归海刀刀
发布2025-06-09 13:54:49
发布2025-06-09 13:54:49
16000
代码可运行
举报
文章被收录于专栏:归海刀刀归海刀刀
运行总次数:0
代码可运行

 01

1. 直接使用语法
代码语言:javascript
代码运行次数:0
运行
复制
entrytitle 'R' {sup '2'};坐标轴标签× 图例×。
entrytitle "R(*ESC*){unicode '00B2'x}";坐标轴标签√ 图例×。
entrytitle "(*ESC*){unicode mu}(*ESC*){unicode hat} =";坐标轴标签√ 图例×。
label="C(*ESC*){unicode '2098'x}(*ESC*){unicode '2090'x}(*ESC*){unicode '2093'x}"
 有些字体显示不了,显示模糊。
图片
图片
图片
图片
2. 直接copy上下标
代码语言:javascript
代码运行次数:0
运行
复制
entrytitle  "R²"; 
坐标轴标签√ 图例√。
图片
图片
3. Drawtext绘制文本
代码语言:javascript
代码运行次数:0
运行
复制
drawtext 'C' {sub 'max'} / x=-9.8 y=50.6 rotate=90 DRAWSPACE=DATAPERCENT WIDTH=100 WIDTHUNIT=PERCENT;
可以添加在任何地方,需注意绘图顺序和图层覆盖的情况。
4. 改字号和设置偏移量(https://support.sas.com/kb/24/934.html )
图片
图片
图片
图片
代码语言:javascript
代码运行次数:0
运行
复制
/* Create sample data */
data a;
   input x y;
   datalines;
25.6
37.2
18.5
43.5
58.3
;
run; 

/* Set the graphics environment */
goptions reset=all border htitle=pt htext=pt;
         
symbol1 interpol=none value=dot color=CX7C95CA height=1.7; 
axis1 label=(height= pct ' ') minor=none offset=(pct,pct); 
axis2 label=(angle= height= pct ' ') minor=none;

title1 height=pt '  ';  
/* Add a superscript to the title */
title2 height=pt 'Superscripts and Subscripts' move=(+.3,+) height=pt '(1)';

/* Add extra white space below the graph */
footnote1 height=pt ' ';
footnote2 height=pt angle=' ';  

/* Create the graphics output */
proc gplot;
   plot y*x / haxis=axis1 vaxis=axis2;

/* Horizontal axis label */
   note font='Albany AMT/bold'
        move=(,)pct height=pt 'H'  move=(+.5,-.75) height=pt '2'
        move=(+.8,+.75) height=pt 'O'  move=(+.5,+.75) height=pt '2';

/* Vertical axis label */
   note font='Albany AMT/bold'
        move=(,)pct height=pt 'N' move=(+.5,+.75) height=pt '2';
   note font='Albany AMT/bold'
        move=(,)pct height=pt 'H' move=(+.5,-.75) height=pt '2';
run;
quit;

测试过程的代码如下:

代码语言:javascript
代码运行次数:0
运行
复制
proc template;
 define statgraph dynamics;
  mvar SYSDATE9 SCALE;
  nmvar BINS;
dynamic VAR VARLABEL;
  begingraph;
   entrytitle 'R' {sup '2'};
   entrytitle "R(*ESC*){unicode '00B2'x}";
   entrytitle "(*ESC*){unicode mu}(*ESC*){unicode hat} =";
   layout overlay / xaxisopts=(label="C(*ESC*){unicode '2098'x}(*ESC*){unicode '2090'x}(*ESC*){unicode '2093'x}"
      labelattrs=(FAMILY="Times New Roman")) yaxisopts=(label=VARLABEL);
    histogram VAR / scale=SCALE group=GHDD nbins=BINS name="GHDD";
    densityplot VAR / normal();
    drawtext 'C' {sub 'max'} / x=-9.8 y=50.6 rotate= DRAWSPACE=DATAPERCENT WIDTH= WIDTHUNIT=PERCENT;
    discretelegend "GHDD";
   endlayout;
  endgraph;
 end;
run;

%let bins=;
%let scale=count;

ods escapechar="^";
data GHDD;
set sashelp.class;
 GHDD=ifc(sex="F","R²","C^{sub min)");
run;

/*ods rtf file="D:\test.rtf";*/
proc sgrender data=GHDD
 template=dynamics;
dynamicvar="Height" varlabel="C^{sub max)";
run;
/*ods rtf close;*/

绘图TEXT命令: Text Commands

代码语言:javascript
代码运行次数:0
运行
复制
{ SUB "string" | dynamic }

text-command that specifies that the string or dynamic is to appear as subscript text. See “Rules for Unicode and Special Character Specifications” on page 1208 Example entry "y = " b{sub "0"} " + b" {sub "1"} "x";

代码语言:javascript
代码运行次数:0
运行
复制
{ SUP "string" | dynamic }

text-command that specifies that the string or dynamic is to appear as superscript text. See “Rules for Unicode and Special Character Specifications” on page 1208 Example entry "R" {sup "2"} " = " {format (6.4) RSQUARED} ;

代码语言:javascript
代码运行次数:0
运行
复制
{ UNICODE "hex-string"x | keyword | dynamic }

text-command that specifies a glyph (character) to be displayed using its Unicode specification or keyword equivalent. "hex-string"x a four-byte hexadecimal constant that represents a UNICODE character in the current font. For a complete listing, see http://unicode.org/charts/charindex.html. keyword a SAS keyword for a UNICODE character. For a listing of keywords supplied by SAS, see “Reserved Keywords and Unicode Values” on page 1208. dynamic a dynamic variable that resolves to either "hex-string"x or a keyword for a UNICODE character. Note The UNICODE text command attempts to access a UNICODE value in the current font. Not all fonts support accessing characters through their UNICODE value. Some fonts support only a limited set of UNICODE values. If the UNICODE value is not accessible, then the command might be ignored or a nonprintable character might be substituted. See “Using UNICODE Text” on page 1207 “Rules for Unicode and Special Character Specifications” on page 1208 Example entry {unicode alpha} "=" CONF; entry {unicode "03B1"x} "=" CONF;

参考链接: https://blog.csdn.net/weixin_49282401/article/details/119687253

尊敬的读者,首先感谢您对本篇文章的关注和阅读。在此,本小编想要说明的是,以上所述内容都是经过笔者认真整理和撰写的,但限于个人能力和知识水平等因素,难免存在疏漏或错误之处。如有不当之处,敬请包涵并指正,本小编将虚心接受您的批评与建议,并严谨修正文章。再次感谢您对本篇文章的支持与厚爱。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2025-06-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 归海刀刀 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1. 直接使用语法
  • 2. 直接copy上下标
  • 3. Drawtext绘制文本
  • 4. 改字号和设置偏移量(https://support.sas.com/kb/24/934.html )
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档