SAS author's tip: Alternative ODS destinations

Neil Constable is a Principal Education Consultant at SAS in the United Kingdom, where he applies his extensive knowledge of Base SAS, SAS Enterprise Guide, and the SAS business intelligence tools. He's also the author of SAS Programming for Enterprise Guide Users, Second Edition--and this week's featured tip.

You can get to know Neil better and read a free chapter from his book by visiting his author page. And, if you like this week's tip on alternative output destinations, there's a featured SAS tip from Neil on SAS Enterprise Guide and Global Projects.

The following excerpt is from SAS Press author Neil Constable and his book "SAS Programming for Enterprise Guide Users, Second Edition" Copyright © 2010, SAS Institute Inc., Cary, North Carolina, USA. ALL RIGHTS RESERVED. (please note that results may vary depending on your version of SAS software)

Alternative Output Destinations

Finally we look at some alternative ODS destinations you might find useful.

First you might want to redirect the output of a task to a comma-separated value (CSV) file. This is a general purpose unformatted way of storing data that many third-party applications can use. For example, many relational databases have the ability to export or import CSV files.

The syntax for creating a CSV file is as follows:

ODS CSVALL FILE="yourfile.csv";

This code writes all your headers, footers, titles, and data to a CSV file. When you open the file by double-clicking on it from an Explorer window, the .csv file extension ensures that Windows uses a suitable viewer.

Here is an alternative syntax:

ODS CSV FILE="yourfile.csv";

This is an older version of the destination and does not write headers and footers to the CSV file.

If you are interested in moving your output to Microsoft Excel and you are using Microsoft Office 2002 or later, then the EXCELXP destination is a good one to use. This has to be specified in a slightly different way. Use the following code:

ODS TAGSETS.EXCELXP FILE="yourfile.xls";

The reason this is specified slightly differently is that there is not a shortcut definition for it. In fact, HTML is just a shorthand way of saying TAGSETS.HTML4.

What this actually produces is an Extensible Markup Language (XML) file that Microsoft Excel understands. You will not be able to open it from within SAS Enterprise Guide, but in Windows you can just double-click on it and it will open in Excel. Try opening it in Notepad as well to see what is actually created.

When using either of these methods, don’t forget that you might want to stop SAS Enterprise Guide from doing its own output.

Again, in both cases you should really close the destinations, but SAS Enterprise Guide does put in the following line:

ODS _ALL_ CLOSE;

so you don’t have to.

tags: CSV file, EXCELXP, neil constable, ods, output destinations, sas, sas author's tip, sas enterprise guide, sas press, SAS Programming for Enterprise Guide Users, sas tip, XML

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <p> <pre lang="" line="" escaped=""> <q cite=""> <strike> <strong>