How to modify the second level Table of Contents entry using ODS and DATA _NULL_


There are two ways to direct output to the ODS destinations with DATA _NULL_: using the FILE PRINT statement and FILE PRINT ODS.

When using FILE PRINT ODS, you can change the second level bookmark in the table of contents (TOC) via the OBJECTLABEL= suboption.

ods pdf file='fileprintods.pdf';
/* Specify a null label for the first TOC node */
ods proclabel='Sample text here';
data _null_;
   file print ods=(objectlabel='Second level node');
   set sashelp.class;
   put _ods_;
run;


Beginning in SAS® 9.2, setting OBJECTLABEL to a null value will eliminate the second level node.

file print ods=(objectlabel='');

/* With FILE PRINT, OBJECTLABEL= suboption is not valid.     */
/* TITLE is used to overwrite the second level node instead. */
ods pdf file='fileprint.pdf';
ods proclabel='PROCLABEL for second DATA step';
title '00'x;  /* Specify a null for the title */
data _null_;
   file print;
   set sashelp.class;
   put name;
run;
ods pdf close;


Beginning in SAS 9.2, ODS DOCUMENT and PROC DOCUMENT can be used to eliminate the second level node when using FILE PRINT.

ods document name=test;
ods pdf file="original.pdf";

data _null_;
   file print notitles;
   set sashelp.class;
   put name;
run;

ods pdf close;
ods document close;

proc document name=test;
   ods listing;
   list / levels=all details;
   move \Datastep#1\FilePrint1#1 to ^; run;
   list / levels=all details; run;
   delete \Datastep#1; run;
   setlabel \FilePrint1#1 "First Node";
   list / levels=all details; run;
   ods listing close;
   ods pdf file="replay.pdf";
   replay;  run;
   ods pdf close;
quit;