Is there a style that mimics the LISTING destination that I can use in HTML, PDF, or RTF destinations?


By design each of the ODS destinations has a different look because each one has a different audience. HTML is meant to be viewed on the Web, and PDF is meant to be viewed or printed from Adobe Acrobat Reader. Therefore, there is not a predefined style that makes the output from the other destinations look like ODS LISTING (the Output window).

The PROC TEMPLATE code in the Full Code section makes a style that attempts to mimic the LISTING output by changing fonts to a monospace font (in this case, Courier) and reducing the cell padding of the tables. Note the change to the grid lines to accommodate the table grids that are used by TABULATE and PROC FREQ's crosstab tables.

The DATA Step code in the Full Code section shows an alternate method to create PDF output which mimics the LISTING destination. This logic is applicable to other ODS destinations.


Full Code

The PROC TEMPLATE code shown for Method 1 makes a style that attempts to mimic the LISTING output by changing fonts to a monospace font (in this case, Courier) and reducing the cell padding of the tables. Note the change to the grid lines to accommodate the table grids that are used by TABULATE and PROC FREQ's crosstab tables.

The DATA Step code shown for Method 2 demonstrates an alternate method to create PDF output which mimics the LISTING destination. Method 2 is dependent upon traditional LISTING syntax like Linesize and Pagesize.

/* Method 1 */
proc template;
  define style styles.likelista;
   parent=styles.printer;
    replace fonts /
     'BatchFixedFont' = ("Courier",8pt)
     'TitleFont2' = ("Courier",8pt)
     'TitleFont' = ("Courier",8pt)
     'StrongFont' = ("Courier",8pt)
     'EmphasisFont' = ("Courier",8pt)
     'FixedEmphasisFont' = ("Courier",8pt)
     'FixedStrongFont' = ("Courier",8pt)
     'FixedHeadingFont' = ("Courier",8pt)
     'FixedFont' = ("Courier",8pt)
     'headingEmphasisFont' = ("Courier",8pt)
     'headingFont' = ("Courier",8pt)
     'docFont' = ("Courier",8pt);
    style table from output /
      cellpadding = 2pt
      cellspacing = 0pt
      background=white
      rules=none
      frame=void;
    replace color_list    /
     'link' = black
     'bgH' = white
     'fg' = black
     'bg' = white;
 end;
 define style styles.likelistb;
  parent=styles.likelista;
    style table from output /
      cellpadding = 2pt
      cellspacing = 0pt
      background=white
      rules=all
      frame=void;
 end;
run;

 ods noproctitle;
 ods pdf file='method1.pdf' style=styles.likelista notoc;

   proc print data=sashelp.class;
   run;

 ods pdf style=styles.likelistb;

   proc freq data=sashelp.class(obs=10);
    tables age*name;
   run;

 ods _all_ close;

 /*Method 2*/
 options ls=120 ps=84 center nodate nonumber orientation=portrait;
 ods listing file='c:\temp\tmp.lst';

   proc print data=sashelp.class;
      title 'Get listing look in PDF';
      footnote "Footnote";
   run;

   
  proc freq data=sashelp.class(obs=10);
    tables age*name;
  run;

 ods listing close;

 title;
 footnote;
 ods pdf file='method2.pdf' notoc;

   data _null_;
    infile 'c:\temp\tmp.lst' length=lg;
    input @1 line $varying400. lg;
    file print ;
    put @1 line $varying. lg;
   run;

 ods pdf close;
 ods proctitle;


Output

Method 1

Method 2