寻找将标题/脚注作为表格的一部分嵌入的建议(请参阅下文-使复制和粘贴到其他文档更容易)
到目前为止已探索的选项
1)PROC报告-计算 PAGE 之前(计算机不支持对齐选项,并且未找到任何可靠的选项来使title1中的“ y的第x页”文本右对齐,例如计算和插入空白。此外,我需要使标题居中对齐
2)ODS RTF-BODYTITLE和BODYTITLE_AUX选项(将标题/脚注显示为正文的一部分,但不完全是表格的一部分-不容易选择为一个对象)
答案 0 :(得分:0)
编辑RTF可能更容易。
读取文件并计数cf1 {Page
{\ field {* \ fldinst {NUMPAGES
}的{\ field {* \ fldinst {PAGE}}}
}}} \ cell}
然后再读一遍,并在编写新行时修改这些行
文件。
答案 1 :(得分:0)
SAS ODS内联样式指令^{PAGEOF}
将在输出文件中生成第y页x 个输出。由于输出是Word 字段,因此您可能需要Ctrl-A, F9
才能在打开文档时计算字段值。
RTF目标在文档的页眉和页脚部分呈现TITLE
和FOOTNOTE
,因此需要技巧来生成每个表的“标题”和“页脚”。从我作为文档阅读器的角度来看,PAGEOF的最佳位置应该在标题部分,而不是表标题的一部分。
ods escapechar = '^';
title justify=right '^{PAGEOF}';
ODS TEXT =可用于在进行统计报告的Proc TABULATE
之前和之后添加段落。 ODS TEXT =将处理内联ODS格式设置指令(包括PAGEOF
)。有关更多信息,请参见SAS® 9.4 Output Delivery System: User’s Guide, Fifth Edition, ODS ESCAPECHAR Statement。
ods text='
Narrative before tabular output via ODS TEXT=
^{NEWLINE} Inline styling directives will be processed.
^{NEWLINE} ^{STYLE [color=green]Mix and match}
^{NEWLINE} Let''s see why.
';
ods text='Here you are at ^{STYLE ^{PAGEOF}}';
* This might require Word field computation or print preview to get proper numbers;
取决于目的地的STYLE =,例如ods rtf style=plateau …
ODS TEXT可能具有一些轮廓或其他样式问题。
如果您是rtf核心,ODS TEXT=
也可以将rtf代码直接注入目标流中以产生 any rtf可能的产品。在以下示例中:
^S{attr-name=attr-value}
用于强制文本容器为页面宽度的100%。^{RAW
函数用于引入原始rtf编码。实际rtf的每个{
都是使用{RAW
引入的。请注意如何将RAW嵌套。
ods text = '^S={outputwidth=100% just=c} ^{RAW \rtf1\ansi\deff0^{RAW \fonttbl^{RAW \f0 Arial;}}
\qc\f0\fs20\i\b
This output created with ODS TEXT=\line
Injecting raw RTF coding\line
Such as ^{RAW \cf11\ul colored and underlined}\line
Not for the casual coder.
}';
某些过程,例如Proc PRINT
具有样式选项,例如style(table)=[ … ]
,其中可以指定pretext=
和posttext=
,并且这样的文本将在之前和之后呈现。 rtf表格-这些文字不是表格的一部分,并且单击Word的“表格选择”图标()时不会被“拾取”。同样,不幸的是,没有为ODS样式指令处理pretext =和posttext =值。但是,值可以是原始rtf!
演示内联样式的PRETEXT不兑现:
proc print
data=sashelp.class (obs=3)
noobs
style(table)=[
pretext='^{STYLE [color=Red]Above 1 ^{NEWLINE}Above 2 - Pretext= is unprocessed ODS directives}'
posttext='^{STYLE [color=Green] Below}'
]
;
run;
PRETEXT演示为通过的原始rtf(第一个字符为{
时)
proc print
data=sashelp.class (obs=3)
noobs
style(table)=[
pretext='{\rtf1\ansi\deff0{\fonttbl{\f0 Arial;}}
\qc\f0\fs20\i\b This output created with SAS PRETEXT=
\line Injecting raw RTF coding
\line Not for the casual coder.
}'
posttext='{\rtf1\ansi\deff0{\fonttbl{\f0 Arial;}}
\qc\f0\fs20\i\b This output created with SAS POSTTEXT=
\line Injecting raw RTF coding
\line Not for the casual coder.
}'
]
;
run;
Proc TABULATE
没有style(table)
选项,但是TABLE
语句确实具有选项:
/ CAPTION=
(在OPTION ACCESSIBLETABLE;
有效时呈现)
TABLE
语句中有页面尺寸,则说明值会被覆盖。/ STYLE=[PRETEXT='...' POSTTEXT='...']
TABULATE
不:
LINE
中的Proc REPORT
语句)请考虑以下带有accessibletable
的表格示例,以获取一些医疗数据。一些变量用于:
data have;
call streaminit(123);
do _n_ = 1 to 1e3 - 300 + rand('uniform',600);
patientId + 1;
category = ceil(rand('uniform',4));
age = 69 + floor(rand('uniform',20));
cost = 500 + floor(rand('uniform',250));
length sex $1;
sex = substr('MF', 1+rand('uniform',2));
array flags flag1-flag3; * some flags asserting some medical state is present;
do over flags; flags = rand('uniform', 4) < _i_; end;
output;
end;
label age = 'Age' cost = 'Cost' sex = 'Sex';
run;
* Precomputation step;
* Use SQL to compute the N= crossings and make that part of a
* new variable that will be in the tabulation column dimension;
proc sql;
create table for_tabulate as
select
*
, catx(' ', 'Category', category, '( n =', count(*), ')')
as category_counted_columnlabel
from have
group by category
;
quit;
制表报告
options accessibletable;
proc tabulate data=for_tabulate ;
class
category_counted_columnlabel
sex
/
missing style=[fontsize=18pt]
;
var age cost flag1-flag3;
table
/* row dimension */
age * ( mean std min max median n*f=8.) * [style=[cellwidth=0.75in]]
N='Sex' * sex
cost * ( mean std min max median n*f=8. )
(flag1 - flag3) * mean = '%' * f=percent5.1
,
/* column dimension */
category_counted_columnlabel = ''
/
/* options */
nocellmerge
caption = "This is caption text is ^{STYLE [color=green]from Mars}^{NEWLINE}Next line"
;
run;
对于9.4M6之前的SAS版本,可以在预计算步骤的输出中添加页面尺寸变量(其值是内联ODS样式化文本作为标题),然后在table语句中指定该变量。像
, '^{NEWLINE}title1' /* SQL step */
|| '^{NEWLINE}title2'
|| '^{NEWLINE}title3'
|| '^{NEWLINE}title4'
as pagedim_title
和
/* tabulate step */
class pagedim_title / style = [background=lightgray fontfamily=Arial textalign=right];
table pagedim_title, …, category_counted_columnlabel = '' … ;