SAS ODS PDF: Table of Contents

Report
Question

Please briefly explain why you feel this question should be reported .

Report Cancel

Here a SAS code sample:

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#2Report#1 TO report#1 ;

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

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

This code produces this TOC

My problem is that I would like to be able to add levels in the TOC without using more procedures (Cf. Note3 in the code sample).

I would like to link directly the TITLE statement in the TOC without using ODS PROCLABEL=”text” or CONTENTS=”text”.

Is it possible (I’m running SAS 9.2)?

solved 0
1 Answer 16 views 0

Answer ( 1 )

    0
    December 28, 2016 at 9:55 pm

    Please briefly explain why you feel this answer should be reported .

    Report Cancel

    I think I see the part of the issue. It looks like it is the PROCLABEL option and the CONTENTS keywords that are being used to build the TOC, not the TITLE keywords. The TITLE keywords simply detail what the heading on each page should be. I’ve taken your example and simplified it a little to illustrate this point:

    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;
    

    Looking through the documentation I’m not sure how this could be nested further but perhaps this will help you find the solution, or help someone else figure out the answer.

    Best answer

Leave an answer

Browse

What is the capital of Egypt ? ( Cairo )

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>