SAS ODS PDF:目录

时间:2016-08-18 13:35:23

标签: pdf sas tableofcontents

这是SAS代码示例:

ODS LISTING CLOSE;
GOPTIONS DEV=SASPRTC;
ODS PDF FILE="test_toc.pdf" CONTENTS=YES ;
ODS DOCUMENT NAME=REPORTTOC(WRITE);

ODS PROCLABEL="1 - Title level 1" ;
TITLE1 "1 - Title level 1" ;
TITLE2 "1.1 - Title level 2: Horsepower" ;
PROC REPORT DATA=SASHELP.CARS(obs=5) NOWINDOWS CONTENTS="1.1 - Title level 2: Horsepower"; 
    COLUMN Horsepower ;
    DEFINE Horsepower / DISPLAY PAGE CONTENTS="" ;*Note1: According to SAS documentation, contents="" should delete "Table 1" from the TOC but it does not work;
RUN;
TITLE2 "1.2 - Title level 2: Type" ;
PROC REPORT DATA=SASHELP.CARS(obs=5) NOWINDOWS CONTENTS="1.2 - Title level 2: Type"; 
    COLUMN type ;
    DEFINE type / DISPLAY PAGE CONTENTS="" ;*Note2: idem;
RUN;

ODS PROCLABEL="2 - Title level 1" ;
TITLE1 "2 - Title level 1" ;
TITLE2 "2.1 - Title level 2: Horsepower" ;
TITLE3 "2.1.1 - Title level 3: Horsepower" ;
PROC REPORT DATA=SASHELP.CARS(obs=5) NOWINDOWS CONTENTS="2.1 - Title level 2: Horsepower"; 
    COLUMN Horsepower ;
    DEFINE Horsepower / DISPLAY PAGE CONTENTS="2.1.1 - Title level 3: Horsepower" ;
RUN;
TITLE2 "2.2 - Title level 2: Type" ;
TITLE3 "2.2.1 - Title level 3: Type" ;
*Note3: Can I add another level of title (TITLE4) in the TOC before the display of this PROC REPORT? ;
PROC REPORT DATA=SASHELP.CARS(obs=5) NOWINDOWS CONTENTS="2.2 - Title level 2: Type"; 
    COLUMN type ;
    DEFINE type / DISPLAY PAGE CONTENTS="2.2.1 - Title level 3: Type" ;
RUN;

ODS DOCUMENT CLOSE;
ODS PDF CLOSE;
GOPTIONS RESET=ALL;
ODS LISTING;

PROC DOCUMENT NAME=REPORTTOC(update);

MOVE Report#2\Report#1 TO report#1 ;

MOVE Report#4\Report#1 TO report#3;
RUN;

ODS PDF FILE='test_toc.pdf' CONTENTS=YES ;
REPLAY; RUN;
ODS PDF CLOSE;
QUIT;

This code produces this TOC

我的问题是我希望能够在不使用更多程序的情况下在TOC中添加级别(代码示例中的注释3)。

我想在不使用ODS PROCLABEL =“text”或CONTENTS =“text”的情况下直接链接TOC中的TITLE语句。

有可能(我正在运行SAS 9.2)吗?

1 个答案:

答案 0 :(得分:0)

我想我看到了问题的一部分。看起来PROCLABEL选项和CONTENTS关键字用于构建TOC,而不是TITLE关键字。 TITLE关键字只是详细说明每个页面上的标题应该是什么。我已经把你的例子简化了一点来说明这一点:

ODS LISTING CLOSE;
ODS PDF FILE="test_toc.pdf" CONTENTS=YES ;
ODS DOCUMENT NAME=REPORTTOC(WRITE);

GOPTIONS DEV=SASPRTC;

ODS PROCLABEL="Proc Label 1" ;
TITLE1 "1 - Title level 1 ";
TITLE2 "1.1 - Title level 2 " ;
TITLE3 "1.1.1 - Title level 3 " ;
TITLE4 "1.1.1.1 - Title level 4 " ;
PROC REPORT DATA=SASHELP.CARS(obs=5) NOWINDOWS CONTENTS="Contents 1"; 
    COLUMN Horsepower ;
    DEFINE Horsepower / DISPLAY PAGE CONTENTS="Contents 2" ;
RUN;

ODS DOCUMENT CLOSE;
ODS PDF CLOSE;
ODS LISTING;

查看文档我不确定如何进一步嵌套,但这可能会帮助您找到解决方案,或帮助其他人找到答案。