Here I'm using proc report with a by statement and proc document to create a table of contents in a PDF file.
I'm wondering why "Level 3" is not displayed by in the list statement output of proc document
and why renaming the Table Item with setlabel creates a new item in the TOC.
1. Default Labels in the TOC
proc sort data=sashelp.class out=class;
by sex;
run;
ods document name=test(write);
proc report data=class;
by sex;
column name age height weight;
define name / display;
define age / display;
define height / display;
define weight / display;
run;
ods document close;
ods pdf file ="&xxtest./reporting/test.pdf";
proc document name=test;
replay;
run;
quit;
ods pdf close;
![basic.JPG basic.JPG](https://communities.sas.com/t5/image/serverpage/image-id/62644i8B19AB1EDD319217/image-size/large?v=v2&px=999)
2. Using labels from proclabel and contents
options label;
proc sort data=sashelp.class out=class;
by sex;
run;
data class;
set class;
retain tmp 1;
run;
ods document name=test(write);
ods proclabel 'Level 1';
proc report data=class contents='Level 2';
by sex;
column tmp name age height weight;
define tmp / order noprint;
define name / display;
define age / display;
define height / display;
define weight / display;
break before tmp / page contents='Level 3';
run;
ods document close;
ods pdf file ="&xxtest./reporting/test.pdf";
proc document name=test;
replay;
run;
quit;
ods pdf close;
![basic2.JPG basic2.JPG](https://communities.sas.com/t5/image/serverpage/image-id/62646iA1DC5182B3DA52DB/image-size/large?v=v2&px=999)
3. Using proc document
options label;
proc sort data=sashelp.class out=class;
by sex;
run;
data class;
set class;
retain tmp 1;
run;
ods document name=test(write);
ods proclabel 'Level 1';
proc report data=class contents='Level 2';
by sex;
column tmp name age height weight;
define tmp / order noprint;
define name / display;
define age / display;
define height / display;
define weight / display;
break before tmp / page contents='Level 3';
run;
ods document close;
proc document name=test;
list/levels=all details;
run;
quit;
proc document name=test;
setlabel \Report#1\ByGroup1#1\Report#1\Report#1 '4.1';
setlabel \Report#1\ByGroup2#1\Report#1\Report#1 '4.2';
setlabel \Report#1\ByGroup1#1\Report#1 '3.1';
setlabel \Report#1\ByGroup2#1\Report#1 '3.2';
setlabel \Report#1\ByGroup1#1 '2.1';
setlabel \Report#1\ByGroup2#1 '2.2';
setlabel \Report#1 '1';
list/levels=all details;
run;
quit;
ods pdf file ="&xxtest./reporting/test.pdf";
proc document name=test;
replay;
run;
quit;
ods pdf close;
![list.JPG list.JPG](https://communities.sas.com/t5/image/serverpage/image-id/62647iF6AD5DCF3E0256E7/image-size/large?v=v2&px=999)
I'm wondering why "Level 3" is not displayed in the list statement output.
![basic3.JPG basic3.JPG](https://communities.sas.com/t5/image/serverpage/image-id/62648iFA470B646808CB11/image-size/large?v=v2&px=999)
We can see that renaming the Table item creates a new entry on the last level rather than the one available at that level.