SAS ESCAPECHAR
1. ESCAPECHAR
详细信息搜索sashelp: Style Attributes Tables
PROC TEMPLATE: Creating a Style Template (Definition): Style Attributes and Their Values (sas.com)
sas help:
Notes | For RTF output, the ~ , * , or # can also be used. The \ is a special RTF character. Therefore, it is recommended that you use an escape character other than \ for RTF output. |
ESCAPECHAR就是做一些 inline formating,简单说就是SAS操作RTF,改变字体颜色,下划线等。
上述意思是使用escapechar时候,不要使用/符号,因为/是个特殊的RTF character。
1.1 (*ESC*)
可以用(*ESC*)代替,作用等同于escapechar=.
1.2原始文本
if you know HTML or RTF control strings, then you can use the ^R capability to insert "native" control strings into the output file. When you use the raw text capability, you are passing the control string directly into the output file for rendering; therefore, this capability should be used by those who are very familiar with ODS and very familiar with the control language of either HTML or RTF.
说白了就是在SAS中用RTF语言。
2. 主要分为
2.1 页码相关的
~{lastpage}
~{thispage}
~{pageof}
2.2 空格换行相关的
~{nbspace num}
~{newline num}
~n ~2n ~3n
~m
~_
2.3 unicode相关的
~{unicode <hex|name>}
2.4 style相关的
有一部分是inline formatting,对一个字符串,控制颜色大小等属性。 SYTLE在ODS LISTING destination中无效。
S必须大写
“~S = { }” 或 "~{ style [ ] }" 效果都一样
fontsize =
fontfamily = 'Courier New'
fontstyle = ITALIC 是加粗斜体。
fontweight = 控制加粗等。和fontstyle会相互影响。
color =
background =
title8 "~{style [ color = blue background = red fontsize = 40 fontfamily = 'courier new' fontstyle = roman fontweight = light] title100 }";
2.4.1
style(report) = {}
2.5 其它
~{super }
~{sub }
~{raw }
2.5.1 插入图片
2.6 同一功能,不同写法
都是加上标:
data a;
a = "str"||byte(178)||")"; *加上标;
a1 = "a{\super 2} Normal";
a2 = "~{super value} value";
c1 = "~R/RTF'\i\b value value";
c2 = "~R/RTF'{\i\b value} value";*~和(*ESC*)一个效果,(*ESC*)是特殊的转义符;
d1 = "(*ESC*)R/RTF'\i\b value value";
d2 = "(*ESC*)R/RTF'{\super value} value"; *{之前的叫原始文本插入,这只有第一个value被打上格式,/RTF说只在rtf格式中生效;
run;
title1 '1 Example of ~R/RTF"\i\b\cf12 value value" RAW function';
title2 "2 Example of ~R/RTF'{\i\b\cf12 value} value' RAW function";
title3 "3 Example of (*ESC*)R/RTF'\i\b\cf12 value value' RAW function";
title4 "4 Example of (*ESC*)R/RTF'{\cf12 value} value' RAW function";
title5 "5 Example of ~{raw \cf12 RAW} RAW function";
title6 "6 Example of (*ESC*){raw \cf12 RAW} RAW function";
title7 "7 Example of (*ESC*)R/RTF'{raw \cf12 RAW}' RAW function";
options nodate nonumber; ods html close; ods escapechar="~"; ods rtf file="./_escapechar.rtf"; e. title1 j = l "lastpage----~{lastpage}"; title2 "PAGEOF-----~{pageof}"; title3 "~THISPAGE----~{thispage}"; title4 "aa~{nbspace 3}cc"; title5 "aa~{newline 3}cc"; title5 'Example of ~{raw \cf12 RAW} RAW function'; title6 "sigma-----~{sigma} a~{sub n}~{super d}"; title7 "sigma-----~{unicode SIGMA}"; title8 "title8~S = {color = red } aaaaaaaa"; title9 "~{style [color = red] aa} aa"; proc print data=sashelp.class(obs=4); run; ods _all_ close;
/*先定义个三线表*/ proc template; define style work.threeline; parent=styles.rtf; class table/ frame=hsides rules=group borderspacing=0pt; end; run; option orientation=landscape ps=30 ls=80 nodate nonumber nobyline; ods path work.templat(update) sashelp.tmplmst(read); ods escapechar='~'; /* 遇到~就转译*/ ods _all_ close; ods rtf file='.\file.rtf' style=work.threeline; title1 color=lightbule '~{thispage} of ~{lastpage}'; /* 用法一:~显示页码*/ title2 '~S={color=red fontsize=20pt} page ~S={foreground=blue} ~{pageof}' ; /*~S调用样式*/ title4 color=lightblue '{\field{\fldinst{page}}}'; /*VBA控制页码*/ title5 '~{style [color=purple fontsize=10pt ] ~{unicode 263B} ~{super A} ~{sub B}}'; /*多层嵌套用法*/ title6 '~S={preimage="1.png"}';/*插入图片*/ data sample; set sashelp.class; if _n_<10; run; proc report data=a nowd headline headskip; columns name ('~{style [background=blue fontsize=15pt ] ~{unicode 263B} Sex-Age}' sex age) ('~S={fontsize=15pt background=lightblue}' weight) height ; define name/ style(header)={just=r cellwidth=120pt font_face=Arial font_weight=bold background=red} style(column)={just=c font_face=Arial font_size=10pt background=blue}; define sex/group; run; ods rtf close; ods listing;
最丑效果图,主要看各种命令效果.....
本文来自博客园,作者:Iving,转载请注明原文链接:https://www.cnblogs.com/SAS-T/p/13375789.html