SAS ODS PDF 正确链接
SAS ODS PDF correct links
目前,我无法生成带有不错书签和 table 内容的漂亮 pdf。
理想情况下,我想要一个如下所示的 pdf 文档:
第 1 页(扉页,纵向)
第 2 页(table 内容,纵向)
第 3 页及更多(子类别中的所有 table,横向)
我的基本做法是这样的:
options orientation=portrait nocenter nodate nonumber;
ods pdf file="C:\xyz.pdf" style=sasweb;
ods escapechar='^';
/* Title page */
title;
ods pdf text="^S={just=c} ^20n Document XYZ";
/* ---------- */
/* Table of contents */
ods pdf startpage=now;
title "Contents";
ods pdf text="Classes A & B";
ods pdf text="^S={URL='#Tab1'} Table 1: Class A";
ods pdf text="^S={URL='#Tab2'} Table 2: Class B";
ods pdf text="Classes C & D";
ods pdf text="^S={URL='#Tab3'} Table 3: Class C";
ods pdf text="^S={URL='#Tab4'} Table 4: Class D";
/* ----------------- */
ods pdf startpage=now; /* Start new page ... */
ods pdf startpage=no; /* ... and define no pagination */
title;
options orientation=landscape;
/* Table list */
%macro make_table(in_data=,title=,link=);
ods pdf anchor="&link";
ods proclabel="&title";
ods pdf text="^2n &title";
proc print data=&in_data contents='' noobs;
run;
%mend;
ods pdf text="Classes A & B";
/* Table 1 */
%make_table(in_data=sashelp.class,title=Table 1: Class A,link=Tab1);
/* Table 2 */
%make_table(in_data=sashelp.class,title=Table 2: Class B,link=Tab2);
ods pdf startpage=now;
ods pdf text="Classes C & D";
/* Table 3 */
%make_table(in_data=sashelp.class,title=Table 3: Class C,link=Tab3);
/* Table 4 */
%make_table(in_data=sashelp.class,title=Table 4: Class D,link=Tab4);
/* ---------- */
ods pdf close;
所有这些设置我遇到了几个问题:
- 关于 pdf 书签和 table 内容,我想链接到 table-titles(例如 "Table 1")和子类别(例如 "Classes A & B" ), 在书签中,子类别应该在第 1 级,table-titles 在第 2 级。但是,"ods pdf anchor" 语句似乎只查找下一个过程,而不是下一个 "ods pdf text"-声明(我更喜欢)。有什么简单的方法可以做到这一点吗?
- 点击超链接和书签对我来说完全是一团糟:有时列名称会被截断(因此我必须向上滚动才能看到它们)以及 Table 3 和 [=44= 的超链接] 4 带我到与相应书签不同的目的地。
- 无论出于何种原因,从 Table 1 到其标题的距离小于所有其他 tables。
这很可能是因为我对输出传送系统缺乏经验,但我现在已经为这些看似简单的问题苦苦挣扎了几个小时。希望有人能帮助我。
经过反复试验,我终于找到了适合我的方法。我不会 post 整个解决方案,因为它相对较长,但总而言之,我做了以下事情:
使用 ods 文档和 proc 将所有需要的数据集打印到其中。
创建了一个新的 ods 文档,并将之前文档的所有输出移至此处,目录结构令我满意 - 这启用了我之前想要的书签结构。我用 obpage 删除了所有分页,并通过 obbnote 添加了 table 标题,并通过 setlabel 添加了正确的书签命名。出于某种原因,我还必须在每个 table 标题前插入两到三个回车符 returns。这样我的link就没有以前那么奇怪了
- 使用ods pdf 和proc 文档创建pdf。在这里,我像以前一样创建了 table 内容,但有一点变化:
而不是这个:
ods pdf text="^S={URL='#Tab1'} ...
ods pdf text="^S={URL='#Tab2'} ...
我用过这个:
ods pdf text="^S={URL='#IDX'} ...
ods pdf text="^S={URL='#IDX1'} ...
这样我就不必使用 ods pdf 锚点 - 对我来说似乎有缺陷的声明(内容 table 中的 linking 不正确)。
尽管如此,我仍然无法 link 将子类别直接添加到标题中,只能添加到以下 table 中。不过,我觉得没问题,所以我不会再尝试了。
如果有人对结果感兴趣,它来了:link
目前,我无法生成带有不错书签和 table 内容的漂亮 pdf。
理想情况下,我想要一个如下所示的 pdf 文档:
第 1 页(扉页,纵向)
第 2 页(table 内容,纵向)
第 3 页及更多(子类别中的所有 table,横向)
我的基本做法是这样的:
options orientation=portrait nocenter nodate nonumber;
ods pdf file="C:\xyz.pdf" style=sasweb;
ods escapechar='^';
/* Title page */
title;
ods pdf text="^S={just=c} ^20n Document XYZ";
/* ---------- */
/* Table of contents */
ods pdf startpage=now;
title "Contents";
ods pdf text="Classes A & B";
ods pdf text="^S={URL='#Tab1'} Table 1: Class A";
ods pdf text="^S={URL='#Tab2'} Table 2: Class B";
ods pdf text="Classes C & D";
ods pdf text="^S={URL='#Tab3'} Table 3: Class C";
ods pdf text="^S={URL='#Tab4'} Table 4: Class D";
/* ----------------- */
ods pdf startpage=now; /* Start new page ... */
ods pdf startpage=no; /* ... and define no pagination */
title;
options orientation=landscape;
/* Table list */
%macro make_table(in_data=,title=,link=);
ods pdf anchor="&link";
ods proclabel="&title";
ods pdf text="^2n &title";
proc print data=&in_data contents='' noobs;
run;
%mend;
ods pdf text="Classes A & B";
/* Table 1 */
%make_table(in_data=sashelp.class,title=Table 1: Class A,link=Tab1);
/* Table 2 */
%make_table(in_data=sashelp.class,title=Table 2: Class B,link=Tab2);
ods pdf startpage=now;
ods pdf text="Classes C & D";
/* Table 3 */
%make_table(in_data=sashelp.class,title=Table 3: Class C,link=Tab3);
/* Table 4 */
%make_table(in_data=sashelp.class,title=Table 4: Class D,link=Tab4);
/* ---------- */
ods pdf close;
所有这些设置我遇到了几个问题:
- 关于 pdf 书签和 table 内容,我想链接到 table-titles(例如 "Table 1")和子类别(例如 "Classes A & B" ), 在书签中,子类别应该在第 1 级,table-titles 在第 2 级。但是,"ods pdf anchor" 语句似乎只查找下一个过程,而不是下一个 "ods pdf text"-声明(我更喜欢)。有什么简单的方法可以做到这一点吗?
- 点击超链接和书签对我来说完全是一团糟:有时列名称会被截断(因此我必须向上滚动才能看到它们)以及 Table 3 和 [=44= 的超链接] 4 带我到与相应书签不同的目的地。
- 无论出于何种原因,从 Table 1 到其标题的距离小于所有其他 tables。
这很可能是因为我对输出传送系统缺乏经验,但我现在已经为这些看似简单的问题苦苦挣扎了几个小时。希望有人能帮助我。
经过反复试验,我终于找到了适合我的方法。我不会 post 整个解决方案,因为它相对较长,但总而言之,我做了以下事情:
使用 ods 文档和 proc 将所有需要的数据集打印到其中。
创建了一个新的 ods 文档,并将之前文档的所有输出移至此处,目录结构令我满意 - 这启用了我之前想要的书签结构。我用 obpage 删除了所有分页,并通过 obbnote 添加了 table 标题,并通过 setlabel 添加了正确的书签命名。出于某种原因,我还必须在每个 table 标题前插入两到三个回车符 returns。这样我的link就没有以前那么奇怪了
- 使用ods pdf 和proc 文档创建pdf。在这里,我像以前一样创建了 table 内容,但有一点变化:
而不是这个:
ods pdf text="^S={URL='#Tab1'} ...
ods pdf text="^S={URL='#Tab2'} ...
我用过这个:
ods pdf text="^S={URL='#IDX'} ...
ods pdf text="^S={URL='#IDX1'} ...
这样我就不必使用 ods pdf 锚点 - 对我来说似乎有缺陷的声明(内容 table 中的 linking 不正确)。
尽管如此,我仍然无法 link 将子类别直接添加到标题中,只能添加到以下 table 中。不过,我觉得没问题,所以我不会再尝试了。
如果有人对结果感兴趣,它来了:link