* ds_contents_outline.sas; options nodate nonumber byline orientation=portrait; ods escapechar="^"; ods listing close; ods rtf file="C:\SAS presentations\Pharma2012\Output\WordDocMapDemo.rtf" startpage=yes /* The CONTENTS and TOC_DATA options generate TOC for SAS 9.2 */ contents device=SASEMF toc_data /* The WORDSTYLE option assigns the name s1 to Heading 1, s2 to Heading 2 and s3 to Heading 3 */ wordstyle="{\s1 Heading 1 \s2 Heading 2 \s3 Heading 3;}" ; /* ODS PROCLABEL '……' generates the 1st level of the title from TOC */ ods proclabel 'Demo 1: PROC PRINT - Customize Toc and Style Template'; /* CONTENTS =’…’ generates the 2nd level of the title from TOC. It can be omitted by specifying CONTENTS=' ' */ proc print data=sashelp.class noobs label contents ='Print 2nd label' style(report)={font_weight=bold pretext='\R\s1Demo 1: PROC PRINT - Customize Toc and Style Template\line\ Print 2nd label' }; var name /style={font_weight=bold cellwidth=3cm just=l}; var sex/style={cellwidth=3cm just=l}; run; /* Manipulate SAShelp.class data set for PROC REPORT */ data class; set sashelp.class; cnt=1; run; ods proclabel 'Demo 1: PROC REPORT - Customize Toc and Style Template'; proc report data=class nowd headskip missing contents ='Report 2nd label' /* PRETEXT='...' places the table titles in the body of the table instead of in Word Header (Zhang 2010) */ style(report)={font_weight=bold pretext='\R\s2Demo 1: PROC REPORT - Customize Toc and Style Template \line\ Report 2nd label\line\ Report 3rd label' }; column cnt name sex; define cnt / group noprint; define name /order order=internal style(column)={font_weight=bold cellwidth=3cm just=left}; define sex /style(column)={cellwidth=3cm just=l}; break before cnt / contents="Report 3rd label" page; run; ods proclabel 'Demo 1: PROC TABULATE - Customize Toc and Style Template'; proc tabulate data=sashelp.class missing contents ='Tabulate 2nd label' ; class sex; /* CONTENTS ='…' generates the 3rd level of the title from TOC. It can be omitted by specifying CONTENTS =” ”. */ table sex all='Total'/ contents ='Tabulate 3rd label' style={font_weight=bold pretext='\R\s3Demo 1: PROC TABULATE - Customize Toc and Style Template \line\ Tabulate 2nd label\line\ Tabulate 3rd label' }; run; ods rtf close; ods listing; /* Use dictionary tables to get data set information from a library SASHELP */ proc sql; create table _dictbl as select * from dictionary.tables where libname="SASHELP" and memtype='DATA'; create table _diccol as select MEMNAME 'Dataset', NAME 'Variable', TYPE, npos, varnum, length, format, informat, label from dictionary.columns where UPCASE(libname)="SASHELP"; create table _dictblmember as select * from dictionary.members where libname="SASHELP" and memtype='DATA'; quit; data datadoc; merge _dictbl _diccol _dictblmember; by MEMNAME; label memname='Dataset'; run; options date number byline orientation=portrait; ods escapechar="^"; ods listing close; /* The BODYTITLE option is used here to display data set names in the Word Document Map */ ods rtf file='C:\SAS presentations\Pharma2012\Output\Datadoc.rtf' contents device=SASEMF toc_data bodytitle contents; ods proclabel 'Data Sets Documentation'; proc sort data=datadoc; /* The BY statement is used to display data set names in the TOC pages and in the Word Document Map */ by memname memlabel; run; ods proclabel "Dataset Documentation"; title; proc report data=datadoc nowd headskip missing split='~' contents='' style(report)=[font=("Arial", 9pt)] style(Summary)=[FONT=("Arial", 9PT)] style(header)=[font_weight=bold FONT=("Arial", 9pt)] style(column)=[FONT=("Arial", 9PT)]; by memname; column libname name type length format label; define libname / group noprint; define name /style(column)={cellwidth=2.5cm just=l}; define type/style(column)={cellwidth=1.8cm just=l}; define length/display style(column)={cellwidth=1.8cm just=left}; define format/display style(column)={cellwidth=2cm just=left}; define label/style(column)={cellwidth=6cm just=left}; break before libname / contents="" page; run; ods _all_ close; ods listing;