Take control of ODS results in SAS Enterprise Guide


When you run a program or task in SAS Enterprise Guide, the application wraps your job in an "ODS sandwich", the colloquial term we use for the ODS statements necessary to create output that can be viewed in your project.

That's convenient for exploring and refining your program, but at some point you might want to use your own ODS statements and options to control the format and appearance of the output. You might find that the default ODS sandwich that SAS Enterprise Guide generates can get in your way.

For example, suppose that you want to create a PDF output with landscape orientation and Legal paper size. The default SAS Enterprise Guide options might be in conflict with some of the options you need. The best approach? Squelch the "automatic" options, and code up your own exactly how you need them. Here's how.

First, change the properties of your SAS program.. Right-click on the program node in your flow and select Properties, or click the Properties icon at the top of the editor window:


In the Properties window, select the Results tab. Then select the Customize results formats [...] option, and uncheck all of the built-in formats.

Next, add the ODS statements and options necessary to produce the results that you want. For example, if you want a PDF file that has a particular format, use something like this:

options orientation=landscape papersize=legal;
ods noproctitle;
/* using ID= to control each ODS dest */
ods pdf (id=custom) 
  /* this file path is on the SAS workspace */
  columns=2 style=journal;
  title "Types by Cylinders and MSRP stats";
proc freq data=sashelp.cars;
  table Type * Cylinders;
proc means data=sashelp.cars;
  class Origin;
  var msrp;
/* print-friendly image options */
ods pdf (id=custom) dpi=300 startpage=no;
ods graphics / 
  noborder scale=on
  height=2in width=2.5in;
title "Distribution";
proc sgplot data=sashelp.cars;
	histogram msrp;
	density msrp;
ods pdf (id=custom) close;

Sample result:
Link to PDF
Some notes about this program:

  • The FILE= option on the ODS PDF statement refers to the file that you want to create in the file system of your SAS workspace, not your local machine. SAS Enterprise Guide will offer to download this file for you to view, but if you want complete control over where it lands on your local PC, use the Copy Files task to download it.
  • If you run this program in SAS Enterprise Guide without turning off the other Results formats, the final PDF output won't have all of the attributes you expect. For example, the graph might look slightly different. So if this PDF is your ultimate objective, be sure to suppress the automatic results from SAS Enterprise Guide.
  • Use this same technique to create custom HTML output, or ODS POWERPOINT (new in 9.4), ODS EPUB (new in 9.4) or even ODS HTML5 (hey! new in 9.4).

For a minimalist, fast-running SAS program, you can use this technique to suppress the fancy (bulkier) ODS results and rely on the old-school LISTING format. In the Results properties for your program, uncheck all output destinations except for Text. If your program generates only text-based output that you want to view quickly, this will turn SAS Enterprise Guide into a speedy-quick results-generating machine...just like you might be accustomed to from your old PC SAS days.

See also

Destination Known: Programmatically Controlling Your Output in SAS Enterprise Guide, by Aaron Hill
[VIDEO] New Destinations in ODS: PowerPoint, HTML5, EPUB, EXCEL
Tip Sheet for ODS PDF


About Author

Chris Hemedinger

Director, SAS User Engagement

+Chris Hemedinger is the Director of SAS User Engagement, which includes our SAS Communities and SAS User Groups. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies


  1. As you eloquently show, SAS Enterprise Guide is such a flexible tool for business users wanting point and click functionality and programmers who may want customization. Good point about using this method for the new SAS 9.4 ODS statements too...

  2. Bruno Müller on

    Thanks for another great blog post. To extend on your example, I put the files in the location of the SAS WORK library using this code:

    %let myWorkLocation = %sysfunc(pathname(work));
    ods tagsets.ExcelXP file="&myWorkLocation/sample.xml" style=htmlblue;

    this allows it to run on any SAS server (Linux/Unix)
    and since the copy file task also supports macro variables, this works just great

  3. Chris, thanks for the help and it does help. Sometimes it is really hard to undstand the different between EG and base SAS. For example, semes like the Base SAS html output only has one file but EG will generate two files one is .htm and another is .css file for the style. I actually asked some people from SAS EG team at SAS Global forum at DC last month and they cannot tell me why.....

    • Chris Hemedinger
      Chris Hemedinger on

      Tao, EG references a local CSS file that is installed with EG, instead of including the CSS inline within the HTML results. But, you can use custom ODS statements or "server-side" styles (see how to manage that in Tools->Style Manager).

  4. Hi Chris! I am trying to output pdf result of SAS programs running in EG (by specify ODS options instead of using EG default) to sharepoint site. However, my SAS administrator at my site had problems to schedule and output the pdf under sharepoint site. If I run my program in EG without specify 'file=', then I could find the result in EG but have to do several click to download my pdf result (have to go to results tab in EG and click download button to see my pdf file). However, if I specify 'file=??????' (my sharepoint location), after i ran my code and click download button, it always shows that 'SAS EG has encountered a problem' with details as below. just want to know if there is anything I could do to make my output to sharepoint successful? Thanks

    Unable to download file.
    -------------------------- Technical Information Follows --------------------------
    Exception Details:
    Exception type:  System.IO.FileNotFoundException
    Message:         Unable to download file.
    Source:          SAS.EG.ProjectElements
    Target Site:     EnsureCached
    Stack Trace:
       at SAS.EG.ProjectElements.ODSResult.EnsureCached()

    • Chris Hemedinger
      Chris Hemedinger on


      There are some tips for targeting SharePoint in this SAS Global Forum paper.

      But it's possible that these don't work well in a scheduled job if the account running the job cannot access SharePoint as a network resource (may require domain authentication). When running in EG under your account, the publishing might work but then EG might not be able to "fetch" the file for view within the project. You might need to instead simply visit the SharePoint URL where your results are expected and then verify them via your browser.

  5. Pingback: Using the ODS statement to add layers in your ODS sandwich - The SAS Dummy

  6. Pingback: How to view or create ODS output without causing SAS® to stop responding or run slowly - SAS Users

  7. Pingback: Using the ODS statement to add layers in your ODS sandwich - The SAS Dummy

Leave A Reply

Back to Top