Combined Program

Now that you have created output for the various applications that you want to use, you can combine the different programs into a single program. You can create an ODS document to store your output objects. You can then replay your output or modify your output objects without having to resubmit any procedures.
CAUTION:
The following program contains numbered callouts that help explain specific parts of the program. When you copy and paste this program into a SAS code editor, the callouts are copied as well, which results in errors. If you want to copy and paste this program, use Combined Program without Callouts.
Combined Program with Callouts
proc sort data=sashelp.prdsale out=prdsale;
    by Country;
run;
options nodate nonumber;
1ods document name=work.prddocument(write);

2ods html path='your-directory-path' body='bodyPrdsale.htm'
        contents='contentsPrdsale.htm'
        frame='framePrdsale.htm'
        style=Science;

3ods rtf file='your-file-path/RTFPrdsaleCustom.rtf' style=Science;

4ods powerpoint file='your-file-path/PrdsaleCustom.ppt' style=PowerPointDark;
5ods pdf file='your-file-path/PDFPrdsaleCustom.pdf'         
        contents=yes pdftoc=2 style=Science;
6ods epub file="your-file-path/prdsaleBookCustom.epub"
    title="My First ODS EPUB E-book"
    options(creator="SAS Programmer" 
    description="Sales Figures for First Quarter by Product" 
    subject="PROC TABULATE, PROC UNIVARIATE, and PROC SGPANEL"
    type="ODS EPUB book");
 

title 'Actual Product Sales';
title2 '(millions of dollars)';

proc tabulate data=prdsale 7style=[fontweight=bold];   
    class region division prodtype /8 style=[textalign=center];   
    classlev region division prodtype / 9style=[textalign=left];   
    var actual / 10style=[fontsize=3];   
    keyword all sum;
    keylabel all='Total';   
    table (region all)*(division all*11[style=[backgroundcolor=yellow]]),
          (prodtype all)*(actual*f=dollar10.) /
          style=[bordercolor=blue] box=[label='Region by Division and Type'
          12style=[fontstyle=italic]];   
run;

13ods rtf exclude all;
14ods select ExtremeObs Quantiles Moments;
title "PROC UNIVARIATE Output";
title2;
     
proc univariate data=prdsale;
    by Country;
    var actual;
run;

15ods rtf select all;
16ods pdf select none;
      
title 'Sales Figures for First Quarter by Product';
proc sgpanel data=prdsale;
    where quarter=1;
    panelby product / novarname;
    vbar region / response=predict;
    vline region / response=actual lineattrs=GraphFit;
    colaxis fitpolicy=thin;
    rowaxis label='Sales';
run;

17ods exclude PRINT;
18ods tagsets.excelxp file='your-file-path.Prdsale.xls' style=Science;
19ods tagsets.excelxp select PRINT;
title "PROC PRINT Output";
proc print data=sashelp.prdsale;
run;
20ods _all_ close;
21ods html;
1 The ODS DOCUMENT statement creates the document Work.PrdDocument. Work.PrdDocument stores all of the output generated between the opening ODS DOCUMENT statement and the ODS _ALL_ CLOSE statement.
2 The ODS HTML statement specifies the names and paths for the body, contents, frame, and page files. The STYLE=SCIENCE option applies the Science style to all HTML output.
3 The ODS RTF statement with the FILE= option opens the ODS RTF destination. It specifies the name and path for the RTF output file. The STYLE=SCIENCE option applies the Science style to all RTF output.
4 The ODS POWERPOINT statement with the FILE= option opens the ODS POWERPOINT destination. It specifies the name and path for the output file. The STYLE=PowerPointDark option applies the PowerPointDark style to all PowerPoint output.
5 The ODS PDF statement with the FILE= option opens the ODS PDF destination. It specifies the name and path for the PDF output file. The CONTENTS=YES option creates a table of contents for your PDF file. The PDFTOC=2 option specifies that the table of contents is expanded to two levels.
6 The ODS EPUB statement with the FILE= option opens the ODS EPUB destination. The OPTIONS option in the ODS EPUB statement specifies suboptions.
7 The STYLE= option specified in the PROC TABULATE statement changes all of the fonts to bold.
8 The STYLE= option specified in the CLASS statement centers the CLASS variable name headings.
9 The STYLE= option specified in the CLASSLEV statement left-justifies the CLASS variable level value headings.
10 The STYLE= option specified in the VAR statement changes the font size of ANALYSIS variable name headings to 3pt.
11 The first STYLE= option specified in the TABLE statement changes the background color of the cells containing the sum totals of REGION and DIVISION to yellow.
12 The second STYLE= option specified in the TABLE statement italicizes the font of the label of the box above the row titles.
13 The ODS RTF statement with the EXCLUDE ALL option excludes all of the output objects from the following PROC UNIVARIATE output.
14 The ODS SELECT statement specifies that the output objects ExtremeObs, Quantiles, and Moments be sent to all open destinations that do not specifically exclude PROC UNIVARIATE output with the EXCLUDE option, such as the previous ODS RTF statement. The ODS statement with the SELECT or EXCLUDE option must be specified after the opening ODS statement.
15 The ODS RTF statement with the SELECT ALL option selects all of the output objects from the following PROC SGPANEL output. It sends the output objects to the ODS RTF destination. The ODS statement with the SELECT or EXCLUDE option must be specified after the opening ODS statement.
16 The ODS PDF statement with the SELECT NONE option selects none of the output objects from the following PROC SGPANEL output. The ODS statement with the SELECT or EXCLUDE option must be specified after the opening ODS statement.
17 The ODS EXCLUDE statement excludes the output object named Print from all open destinations that do not specifically select the Print output object with the SELECT option.
18 The ODS TAGSETS.EXCELXP statement with the FILE= option opens the TAGSETS.EXCELXP destination (which is a member of the MARKUP family of destinations). It specifies the name and path for the XLS output file. You can use the .XML extension instead of the EXCELXP extension. Beginning in Excel 2007, using the XLS extension will invoke a dialog box because of a new security feature that matches the content with the extension. The STYLE=SCIENCE option applies the Science style to all TAGSETS.EXCELXP output.
19 The ODS TAGSETS.EXCELXP statement with the SELECT option selects the output object named Print.
20 The ODS _ALL_ CLOSE statement closes all of the open destinations. This statement is useful when you have multiple destinations open at the same time.
21 Because the ODS _ALL_ CLOSE statement closes all open destinations, it is a good practice to open the ODS HTML destination again at the end of your program. If all of the destinations are closed, you get the following warning in the SAS Log: WARNING: No output destinations active.
Combined Program without Callouts
proc sort data=sashelp.prdsale out=prdsale;
    by Country;
run;
options nodate nonumber;
ods document name=work.prddocument(write);

ods html path='your-directory-path' body='bodyPrdsale.htm'
        contents='contentsPrdsale.htm'
        frame='framePrdsale.htm'
        style=Science;

ods rtf file='your-file-path/RTFPrdsaleCustom.rtf' style=Science;  
ods powerpoint file='your-file-path/PrdsaleCustom.ppt' style=PowerPointDark;
ods pdf file='your-file-path/PDFPrdsaleCustom.pdf'         
        contents=yes pdftoc=2 style=Science;
ods epub file="your-file-path/prdsaleBookCustom.epub"
    title="My First ODS EPUB E-book"
    options(creator="SAS Programmer" 
    description="Sales Figures for First Quarter by Product" 
    subject="PROC TABULATE, PROC UNIVARIATE, and PROC SGPANEL"
    type="ODS EPUB book");
 

title 'Actual Product Sales';
title2 '(millions of dollars)';

proc tabulate data=prdsale style=[fontweight=bold];   
    class region division prodtype / style=[textalign=center];   
    classlev region division prodtype / style=[textalign=left];   
    var actual / style=[fontsize=3];   
    keyword all sum;
    keylabel all='Total';   
    table (region all)*(division all*[style=[backgroundcolor=yellow]]),
          (prodtype all)*(actual*f=dollar10.) /
          style=[bordercolor=blue] box=[label='Region by Division and Type'
          style=[fontstyle=italic]];   
run;

ods rtf exclude all;
ods select ExtremeObs Quantiles Moments;
     
title "PROC UNIVARIATE Output";
title2;

proc univariate data=prdsale;
    by Country;
    var actual;
run;

ods rtf select all;
ods pdf select none;
      
title 'Sales Figures for First Quarter by Product';
proc sgpanel data=prdsale;
    where quarter=1;
    panelby product / novarname;
    vbar region / response=predict;
    vline region / response=actual lineattrs=GraphFit;
    colaxis fitpolicy=thin;
    rowaxis label='Sales';
run;

ods exclude PRINT;
ods tagsets.excelxp file='your-file-path.Prdsale.xls' style=Science;
ods tagsets.excelxp select PRINT;
title "PROC PRINT Output";

proc print data=sashelp.prdsale;
run;
ods _all_ close;
ods html;