|
Using ODS to Export Output in a Markup Language
Version 9 changes and enhancements are
highlighted by a yellow background.
Contents
In Release 8.1, using the
Output Delivery System (ODS), the experimental ODS XML statement
creates XML-formatted documents from SAS procedure output.
Similarly, beginning with Release 8.2, the ODS MARKUP statement can
create output in a variety of markup languages. ODS MARKUP is
experimental in Release 8.2 and is production in
Version 9. The file types that you can create include XML
(Extensible Markup Language), HTML (Hypertext Markup Language), CSV
(comma separated values), WML (Wireless Markup
Language), CHTML (compact HTML), LaTeX (typesetting language), Troff
(typesetting language), and many others.
This document explains the ODS MARKUP statement, provides the
available values for the TAGSET= option, explains how to specify
multiple simultaneous output destinations, and provides examples for
exporting markup languages, including XML documents. In addition,
this document explains how to download and use updated V8
TAGSETS_TEMPLATE.SAS or V9
TAGSETS_TEMPLATE.SAS (Version 9 is shipped with all available
SAS tagsets. If you are running Release 8.2, you can take a peek at
the V9 tagsets, but do not attempt to use them.)
In addition to using the tagsets provided by SAS, you can modify
the SAS tagsets, and you can create your own. See the tagset
syntax documented in a separate article.
The ODS MARKUP
statement opens, manages, or closes one destination. If the
destination is open, you can create markup output such as HTML or
XML. The destination output type for ODS MARKUP is determined by the
TAGSET | TYPE= option, which specifies the kind of markup language.
The syntax for the ODS MARKUP statement is as follows:
ODS MARKUP action ;
ODS MARKUP file-specification(s)
<options> ;
NOTE: The syntax for ODS MARKUP is basically the same as
ODS HTML, except that ODS MARKUP has the TAGSET= option. The STYLESHEET option without an argument is accepted
but does nothing. ODS MARKUP defaults to stylesheet behavior, but it
is up to each tagset to implement it. See the SAS online
documentation for ODS HTML syntax.
An action takes some action
regarding selection and exclusion lists or closes the destination.
Valid actions include the following:
- CLOSE closes the destination and any files associated with it.
- EXCLUDE excludes output objects from the destination.
- SELECT selects output objects for the destination.
- SHOW writes to the SAS log the current selection or exclusion
list for the destination.
If you do not specify an action, you must use a file
specification, which specifies the type of output file and the file
to write to. These files remain open until you either close the
destination with ODS MARKUP CLOSE or specify another file to write
to.
You can specify up to six output
files. While each output file has a logical name
such as body, contents, frame, each file can be used for anything.
It's up to the tagset to use the files appropriately. The
specification for these files has the following form, which
associates a type of file with a particular output file.
NOTE: The value of the TAGSET= option determines the output
type, which is the type of markup language for the destination. For
example, the markup language can be XML, HTML, and so on. See TAGSET |
TYPE= Option.
file-type=file-specification
<(file-specification-suboption(s))>
- file-type
-
is only a hint for what the tagset might write.
The file usage is completely up to the tagset, and there are no
hard rules on this end about what will be written or even which
files will be written to. The file-type can be one of the
following:
- BODY | FILE=
- indicates that the output file will contain the main output
created by ODS MARKUP. For some values of TAGSET=, this output
is an HTML file; for other TAGSET= values, the output is an XML
document, and so on. You cannot open the destination without
specifying a body file. Therefore, BODY= is required or the
destination is closed.
- CODE=
-
indicates that the output file will contain
XSL (Extensible Stylesheet Language) or other relevant style
information.
- CONTENTS=
-
specifies the file that contains the table of
contents. It is generally a hierarchical tree that links to each
output object in the body file. Used primarily by the HTML
tagsets.
- DATA=
- specifies a generic file that can
contain anything. Currently none of the tagsets use it.
- FRAME | TOPFILE=
-
for HTML files, indicates that the output
file integrates the table of contents and the body file. If you
open a frame file, you see a table of contents and a body
file.
- PAGES=
- specifies the file that contains the
table of pages. It is generally a list of links to each page in
the body file.
- STYLESHEET=
-
specifies the use of cascading stylesheets,
which places the style information in the output file or in a
separate external file, or reads style information from an
existing external file.
The form in which you specify STYLESHEET= determines the
results:
- STYLESHEET
-
Does nothing. Really. Not even a syntax
error. For ODS HTML, this option caused stylesheet information
to be written to the output file without creating a separate
external file. For ODS MARKUP this behavior is automatic for
tagsets that have the embedded_stylesheet attribute set to
YES, which is currently only done by the HTML4 tagset.
- STYLESHEET=file-specification
- writes the stylesheet information to the specified
external file.
- STYLESHEET=file-specification (URL="url")
- writes the stylesheet information to the specified
external file, with a link to the stylesheet from the body
file. This is useful, for example, to put stylesheets in a
central storage area, like
http://yourdomain.com/css/styles.css .
- STYLESHEET=(URL="url")
- creates a link from the body file to a previously-created
stylesheet but does not create a style sheet.
TIP: To produce only a stylesheet (that is, no body
file), you can execute the following. Note that the output destination will close and you
will receive a warning that there is no body file.
ods htmlcss stylesheet='mytagsets.css';
- file-specification
- identifies the output file or SAS catalog to write it. It can
be one of the following:
- 'external-file'
- is the physical location of the external file to write to.
Include the complete pathname, file name, and appropriate
extension.
- fileref
- is the SAS name that is associated with the physical
location of the external file to write to. Use the FILENAME
statement to assign a fileref.
- (file-specification-suboption(s))
-
- provide instructions for writing the markup files. Specify
these options inside parentheses next to the file specification in
the FILE=, CONTENTS=, or FRAME= argument.
File specification suboptions include NO_BOTTOM_MATTER,
NO_TOP_MATTER, URL=, and DYNAMIC. See the ODS HTML documentation
of these file specification suboptions.
The options for ODS MARKUP are basically the same as the
documented options for ODS HTML. For example, you can use the
ANCHOR= option to specify the base name for the markup anchor tag
that identifies each output object in the body file, and you can use
the PATH= option to specify the location for the output files. For a
list and an explanation of the available options, see the
documentation for the ODS HTML statement.
ODS MARKUP, however, has an additional option, which is the
TAGSET= option and is explained here.
The syntax for the TAGSET= option is as follows:
- TAGSET | TYPE=value
- specifies a keyword value for a tagset, which is a template
that defines how to create a markup language output type from SAS
format. Templates are created by the TEMPLATE procedure and are
stored in an item store. For example, specifying TAGSET=PHTML
produces a basic HTML output. If you do not specify a TAGSET=
value, ODS MARKUP defaults to XML output.
The values for TAGSET= can be one of the following, which are
the tagsets (templates) supplied by SAS:
- CHTML
- produces a compact, minimal HTML that does not use style
information. It does produce a hierarchical table of contents.
For more information, see Compact
HTML for Small Information Appliances.
- COLORLATEX
- produces color LaTeX, which is a document preparation system
for high-quality typesetting. It also generates a stylesheet.
The output can be rendered to PDF. For more information, see LaTeX: A document
preparation system.
- CSV
- produces comma separated values output, which contains
columns of data that are separated by commas. CSV produces the
tabular output only.
- CSVALL
- produces comma separated values output, which contains
columns of data that are separated by commas. CSVALL produces
the tabular output with titles, notes, and bylines.
- CSVBYLINE
- produces comma separated values output, which contains
columns of data that are separated by commas. CSVBYLINE includes
bylines.
- DEFAULT
- is the default value and produces XML markup, referred to as
ODSXML.
- DOCBOOK
- produces XML output that conforms to the DocBook DTD by
OASIS. For more information, see DocBook Homepage.
- EVENT_MAP
- creates XML output that shows which events are being
triggered and which variables are used by an event to send
output from a SAS process to an output file. When you run a SAS
process with EVENT_MAP, ODS writes XML markup to an output file
that shows all event names and variable names as tags. The
output helps you to create your own tagsets.
- GRAPH
- to be used for SAS/GRAPH output in a later release.
- GTABLEAPPLET
- produces XML output for use with the SAS/GRAPH GTableApplet.
- HTML4
- to be used for embedded stylesheets. HTML4 will replace ODS
HTML in Version 10.
- HTMLCSS
- produces HTML that is similar to ODS HTML with cascading
stylesheets.
- IMODE
- produces HTML that is basically a column of output,
separated by lines. This tagset is used by the Japanese
telephone service provider (NTT). For more information, see All about
i-mode and Mobile
Media Japan.
- LATEX
- produces LaTeX, which is a document preparation system for
high-quality typesetting. It also generates a stylesheet. The
output can be rendered to PDF. For more information, see LaTeX: A document
preparation system.
- LATEX2
- produces LaTeX, which is a document preparation system for
high-quality typesetting. LATEX2 does not require stylesheets.
For more information, see LaTeX: A document
preparation system.
- NAMEDHTML
- creates HTML output like STYLE_POPUP but with all the
objects labeled similar to ODS TRACE. The output helps you to
understand ODS and styles.
- ODSSTYLE
- creates PROC TEMPLATE code for STYLESHEET= file
specification. The output helps you to create and modify styles.
- PHTML
- produces a basic HTML that uses twelve style elements and no
class attributes.
- PYX
- produces PYX, which is a simple, line-oriented notation used
by Pyxie to describe the information communicated by an XML
parser to an XML application. Pyxie is an Open Source library
for processing XML with the Python programming language. For
more information, see Pyxie.
- SASIOXML
- produces generic XML markup.
- SASXML
- produces generic XML markup.
- SASXMOG
- produces XML markup that is similar to the Oracle8iXML
implementation used by ORACLE but is more generic. (Note that
this is the tagset used by the SAS XML LIBNAME engine for
XMLTYPE=GENERIC.)
- SASXMOH
- produces very simple HTML markup. (Note that this is the
tagset used by the SAS XML LIBNAME engine for XMLTYPE=HTML.)
- SASXMOIM
- produces XML markup that is supported by the Open
Information Model (Database Schema Model) proposed by the
Metadata Coalition (MDC) as vendor- and technology-independent,
conforming to the 1.0 specification. (Note that this is the
tagset used by the SAS XML LIBNAME engine for XMLTYPE=OIMDBM.)
- SASXMOR
- produces XML markup that is equivalent to the Oracle8iXML
implementation, which is used by ORACLE. (Note that this is the
tagset used by the SAS XML LIBNAME engine for XMLTYPE=ORACLE.)
- SHORT_MAP
- creates a subset of the XML output that is created by
EVENT_MAP.
- STYLE_DISPLAY
- creates HTML like STYLE_POPUP but produces a sample page of
output for you to click. The output helps you to create and
modify styles.
- STYLE_POPUP
- creates HTML like HTMLCSS, but if you're using Internet
Explorer, STYLE_POPUP displays a window that shows the resolved
ODS style definition for any item that you click. The output
helps you to understand ODS and styles.
- TEXT_MAP
- creates text output as an alternative to EVENT_MAP that
shows which events are being triggered as ODS handles the output
objects.
- TPL_STYLE_LIST
- creates HTML output similar to EVENT_MAP but lists only a
subset of the possible attributes. The information is in a
bulleted list. The output helps you to understand tagsets and
styles.
- TPL_STYLE_MAP
- creates XML output similar to EVENT_MAP but lists only a
subset of the possible attributes. The output helps you to
understand tagsets and styles.
- TROFF
- produces Troff markup, which is a text-formatting
programming language for high-quality photo-typesetters and
laser printers. For more information, see Troff
Resources, GNU Troff
Info, Online Groff
Resources, and Groff (GNU
Troff) - a GNU project,
- WML
- uses the Wireless Application Protocol (WAP) to produce a
Wireless Markup Language (WML) DTD with a simple href list for a
table of contents. For more information, see Wireless
Application Protocol.
- WMLOLIST
- uses the Wireless Application Protocol (WAP) to produce a
Wireless Markup Language (WML) DTD with an option list for the
table of contents. For more information, see Wireless
Application Protocol.
For Version 9, ODS increases the number of SAS
tagsets, which are listed below. To get a list of tagset
names, issue these SAS statements:
proc template;
list tagsets;
Listing of: SASHELP.TMPLMST
Path Filter is: Tagsets
Sort by: PATH/ASCENDING
Obs Path Type
----------------------------------------
1 Tagsets Dir
2 Tagsets.Chtml Tagset
3 Tagsets.Colorlatex Tagset
4 Tagsets.Csv Tagset
5 Tagsets.Csvall Tagset
6 Tagsets.Csvbyline Tagset
7 Tagsets.Default Tagset
8 Tagsets.Docbook Tagset
9 Tagsets.Event_map Tagset
10 Tagsets.GTableApplet Tagset
11 Tagsets.Graph Tagset
12 Tagsets.Html4 Tagset
13 Tagsets.Htmlcss Tagset
14 Tagsets.Imode Tagset
15 Tagsets.Latex Tagset
16 Tagsets.Latex2 Tagset
17 Tagsets.Mvshtml Tagset
18 Tagsets.Namedhtml Tagset
19 Tagsets.Odsstyle Tagset
20 Tagsets.Phtml Tagset
21 Tagsets.Pyx Tagset
22 Tagsets.SASReport Tagset
23 Tagsets.Sasxmiss Tagset
24 Tagsets.Sasxmnsp Tagset
25 Tagsets.Sasxmog Tagset
26 Tagsets.Sasxmoh Tagset
27 Tagsets.Sasxmoim Tagset
28 Tagsets.Sasxmor Tagset
29 Tagsets.Sasxmphp Tagset
30 Tagsets.Short_map Tagset
31 Tagsets.Statgraph Tagset
32 Tagsets.Style_display Tagset
33 Tagsets.Style_popup Tagset
34 Tagsets.Text_map Tagset
35 Tagsets.Tpl_style_list Tagset
36 Tagsets.Tpl_style_map Tagset
37 Tagsets.Troff Tagset
38 Tagsets.Wml Tagset
39 Tagsets.Wmlolist Tagset
40 Tagsets.sasFMT Tagset
41 Tagsets.sasXML Tagset
42 Tagsets.sasioXML Tagset
|
By default, PROC TEMPLATE lists the tagsets in SASHELP.TMPLMST
and SASUSER.TEMPLAT (if it exists). Typically, SASHELP.TMPLMST is a
read-only item store for the SAS tagsets, and SASUSER.TEMPLAT is the
item store for user-defined tagsets.
If you are running Release 8.2, you may want to download
additional tagset definitions and modifications that were developed
after the release was shipped. (Version 9 is
shipped with all available SAS tagsets.)
NOTE: In a network environment, typically you will not
have update access to SASHELP.TMPLMST. When you update your tagsets,
if you do not have update access, SAS creates a tagsets directory in
the default item store SASUSER.TEMPLAT. If you have any problems,
see the SAS System Administrator at your site.
To obtain the updated tagsets:
- Click V8
TAGSETS_TEMPLATE.SAS or V9
TAGSETS_TEMPLATE.SAS and save to a file.
- From SAS, issue the INCLUDE command to copy the contents of
the file to a SAS window.
- Submit the code.
Once the tagsets are built, issue these SAS statements to get a
list of the updated tagset names:
proc template;
list tagsets;
The following list of tagsets shows the updated tagsets in
SASUSER.TEMPLAT and the original tagsets in SASHELP.TMPLMST. This will vary depending upon the version of SAS you
are running.
The SAS System 1
Listing of: SASUSER.TEMPLAT
Path Filter is: Tagsets
Sort by: PATH/ASCENDING
Obs Path Type
----------------------------------------
1 Tagsets Dir
2 Tagsets.Chtml Tagset
3 Tagsets.Colorlatex Tagset
4 Tagsets.Csv Tagset
5 Tagsets.Csvall Tagset
6 Tagsets.Csvbyline Tagset
7 Tagsets.Default Tagset
8 Tagsets.Docbook Tagset
9 Tagsets.Event_map Tagset
10 Tagsets.GTableApplet Tagset
11 Tagsets.Graph Tagset
12 Tagsets.Html4 Tagset
13 Tagsets.Htmlcss Tagset
14 Tagsets.Imode Tagset
15 Tagsets.Latex Tagset
16 Tagsets.Latex2 Tagset
17 Tagsets.Mvshtml Tagset
18 Tagsets.Namedhtml Tagset
19 Tagsets.Odsstyle Tagset
20 Tagsets.Phtml Tagset
21 Tagsets.Pyx Tagset
22 Tagsets.SASReport Tagset
23 Tagsets.Sasxmiss Tagset
24 Tagsets.Sasxmnsp Tagset
25 Tagsets.Sasxmog Tagset
26 Tagsets.Sasxmoh Tagset
27 Tagsets.Sasxmoim Tagset
28 Tagsets.Sasxmor Tagset
29 Tagsets.Sasxmphp Tagset
30 Tagsets.Short_map Tagset
31 Tagsets.Statgraph Tagset
32 Tagsets.Style_display Tagset
33 Tagsets.Style_popup Tagset
34 Tagsets.Text_map Tagset
35 Tagsets.Tpl_style_list Tagset
36 Tagsets.Tpl_style_map Tagset
37 Tagsets.Troff Tagset
38 Tagsets.Wml Tagset
39 Tagsets.Wmlolist Tagset
40 Tagsets.sasFMT Tagset
41 Tagsets.sasXML Tagset
42 Tagsets.sasioXML Tagset
Listing of: SASHELP.TMPLMST
Path Filter is: Tagsets
Sort by: PATH/ASCENDING
Obs Path Type
------------------------------------
1 Tagsets Dir
2 Tagsets.Chtml Tagset
3 Tagsets.Colorlatex Tagset
4 Tagsets.Csv Tagset
5 Tagsets.Csvall Tagset
6 Tagsets.Default Tagset
7 Tagsets.Docbook Tagset
8 Tagsets.Event_map Tagset
9 Tagsets.Graph Tagset
10 Tagsets.Htmlcss Tagset
11 Tagsets.Imode Tagset
12 Tagsets.Latex Tagset
13 Tagsets.Phtml Tagset
14 Tagsets.Pyx Tagset
15 Tagsets.Sasxmog Tagset
16 Tagsets.Sasxmoh Tagset
17 Tagsets.Sasxmoim Tagset
18 Tagsets.Sasxmor Tagset
19 Tagsets.Troff Tagset
20 Tagsets.Wml Tagset
21 Tagsets.Wmlolist Tagset
22 Tagsets.sasXML Tagset
23 Tagsets.sasioXML Tagset
|
In
addition to using the tagsets provided by SAS, you can create your
own tagsets, and you can customize any of the SAS tagsets.
To create a new tagset definition, you use the TEMPLATE procedure
and store it in an item store (which is a SAS file that stores
definitions). Then, you can specify the name of your own tagset to
create markup output.
See Creating
Customized Tagsets to Use with ODS and XML LIBNAME Engine for
documentation on how to create, customize, and use your own tagset.
The
ODS MARKUP statement opens or closes one destination. Like all
single output destinations, you can have only one ODS MARKUP
destination open at once, unless you use the ID= option. (For
information about the ID= option, see the SAS online documentation.)
However, you can specify multiple simultaneous ODS destinations
to produce multiple markup output by
- specifying some of the TAGSET= value keywords as a destination
- specifying any two-level tagset name, such as TAGSETS.PYX,
TAGSETS.STYLE_DISPLAY, or one of your own tagset names.
Specifying a Tagset Keyword as an ODS DestinationFor
several tagset keywords, you can specify them as ODS destinations.
The tagset determines the type of markup. For example, either of the
following set of statements are acceptable:
ods markup body='C:\My Documents\html\class.html' tagset=phtml;
.
.
.
ods markup close;
Or...
ods phtml body='C:\My Documents\html\class.html';
.
.
.
ods phtml close;
Note, however, that the following is not acceptable, because SAS
considers ODS MARKUP and ODS PHTML as separate destinations:
ods markup body='C:\My Documents\html\class.html' tagset=phtml;
.
.
.
ods phtml close;
The tagsets that you can specify as both a TAGSET= value for ODS
MARKUP or as a separate ODS destination are:
- CHTML
- CSV
- CSVALL
- DOCBOOK
- HTML4
- HTMLCSS
- IMODE
- LATEX
- PHTML
- SASREPORT
- TROFF
- WML
- WMLOLIST
You can open a destination and specify the
markup that you want to produce by naming the two-level tagset name.
You can specify all tagsets in this manner. For example:
ods tagsets.sasioxml body='C:\My Documents\xml\test1.xml';
ods tagsets.mytagset body='C:\My Documents\xml\test2.xml';
.
.
.
ods _all_ close;
You can also specify tagset names as follows:
ods markup type=tagsets.sasioxml body='C:\My Documents\xml\test.xml';
The
following is a simple ODS MARKUP example that creates XML markup
from PRINT procedure output. The TAGSET= option for the ODS MARKUP
statement is not specified, which defaults to the tagset ODSXML.
ods listing close;
ods markup body='C:\My Documents\xml\class.xml';
proc print data=sashelp.class;
run;
ods markup close;
Here's the output XML document: CLASS.XML.
The
following ODS MARKUP example creates an XML document and its
DTD-related information document from PROC UNIVARIATE output.
libname myfiles 'C:\My Documents\myfiles';
ods listing close;
ods markup body='C:\My Documents\xml\statepop.xml'
frame='C:\My Documents\xml\statepop.dtd' tagset=default;
proc univariate data=myfiles.statepop;
var citypop_90 citypop_80;
title 'US Census of Population and Housing';
run;
ods markup close;
Here's the XML document: STATEPOP.XML
Here's the DTD: STATEPOP.DTD
The
following ODS example creates both an XML document and HTML output
from the same procedure output. To create two markup outputs
requires two ODS destinations. Because ODS MARKUP is considered one
destination, you cannot specify two tagsets. However, you can
specify one output using ODS MARKUP, then specify the other using
ODS syntax in which you specify the tagset as the destination.
ods listing close;
ods markup body='procprint.xml';
ods chtml body='procprint.html';
proc print data=sashelp.class;
run;
ods _all_ close;
Here's the output XML document: procprint.xml
Here's the output HTML: procprint.html
Specifying tagsets and two-level tagset names
as destinations allow you to open and close multiple destinations,
producing multiple markup output. For example:
ods htmlcss file='C:\My Documents\test1.html';
ods phtml file='C:\My Documents\test2.html';
ods chtml file='C:\My Documents\test3.html';
ods markup file='C:\My Documents\test1.xml';
ods tagsets.event_map file='C:\My Documents\test2.xml';
.
. SAS statements
.
ods htmlcss close;
.
. more SAS statements
.
ods chtml close;
.
. more SAS statements
.
ods _all_ close;
The ODS developers, testers, and
documenters are very excited about the potential of these new
capabilities. You can send electronic mail to ods@sas.com with your comments.
Last Updated: April 24, 2002
|
|