| Return to previous page
|
Now that you have seen what the tag set and structure of the XML output should look like, you can generate some output using your own data. The following links point to some examples demonstating how to use the ODS system to generate XML output. All examples are taken from the sample source programs delivered with the SAS System.
Example 1 is a SAS Version 8 example and Example 2 is the same example for Version 8 TS1 XML.
This example uses the GLMEX program from the SAS Sample Library. Scanning quickly through the file you will see an ODS call as shown below.
ods xml file="glmex.xml";
.
.
.
ods xml close;
This simply means that ODS should output an XML formatted file by the name glmex.xml as shown below.
<?xml version="1.0"?>
<sasxml>
<label id="IDX"/>
<proc>
<title class="SystemTitle">The SAS System</title>
<proc-title class="ProcTitle">The GLM Procedure</proc-title>
<node label="GLM" class="ContentProcName">
<node label="Data" class="ContentFolder">
<leaf label="Class Levels" class="ContentItem">
<output name="Class Level" label="Class Levels" clabel="Class Levels">
<output-object type="table" class="Table" index="IDX">
<style>
<border spacing="1" padding="7" rules="GROUPS" frame="BOX"/>
</style>
<colspec>
<col align="left"/>
<col align="char" alignchar="."/>
<col align="left"/>
</colspec>
<output-head>
<row>
<data class="Header">
<style>
<span col="3"/>
</style>
Class Level Information </data>
</row>
<row>
<data class="Header">Class </data>
<data class="Header">Levels </data>
<data class="Header">Values </data>
</row>
</output-head>
<output-body>
<row>
<data class="RowHeader" name="Class" dname="Class">type </data>
<data class="Data" name="Levels" dname="Levels">7 </data>
<data class="Data" name="Values" dname="Values">clarion clinton<br/>
compost knox<br/>o'neill wabash<br/>webster </data>
</row>
<row>
<data class="RowHeader" name="Class" dname="Class">block </data>
<data class="Data" name="Levels" dname="Levels">3 </data>
<data class="Data" name="Values" dname="Values">1 2 3 </data>
</row>
</output-body>
</output-object>
</output>
</leaf>
...
</node>
</node>
</proc>
</sasxml>
Once you have an XML file, you can go to the short tutorial for examples of what you can do with it.
This example uses the GLMEX program from the SAS Sample Library. Scanning quickly through the file you will see an ODS call as shown below.
ods xml file="glmex.xml";
.
.
.
ods xml close;
This simply means that ODS should output an XML formatted file by the name glmex.xml as shown below.
<?xml version="1.0"?>
<odsxml>
<head>
</head>
<body>
<label name="IDX"/>
<proc class="Body">
<title class="SystemTitle" toc-level="1">The SAS System</title>
<proc-title class="ProcTitle" toc-level="1">The GLM Procedure</proc-title>
<branch class="ContentProcName" toc-level="1" label="GLM">
<branch class="ContentFolder" toc-level="2" label="Data">
<leaf class="ContentItem" toc-level="3" label="Class Levels">
<output name="ClassLevels" label="Class Levels" clabel="Class Levels" class="Body">
<output-object type="table" class="Table">
<style>
<border spacing="1" padding="7" rules="GROUPS" frame="BOX"/>
</style>
<colspecs columns="3">
<colgroup>
<colspec name="1" width="8" type="string"/>
</colgroup>
<colgroup>
<colspec name="2" width="8" type="int"/>
<colspec name="3" width="52" type="string"/>
</colgroup>
</colspecs>
<output-head>
<row>
<header type="string" class="Header" row="1" column="1" column_end="3">
Class Level Information
<style>
<span columns="3"/>
</style>
</header>
</row>
<row>
<header type="string" class="Header" row="2" column="1">Class
</header>
<header type="string" class="Header" row="2" column="2">Levels
</header>
<header type="string" class="Header" row="2" column="3">Values
</header>
</row>
</output-head>
<output-body>
<row>
<header name="Class" type="string" class="RowHeader" row="3" column="1">type
</header>
<data name="Levels" type="int" class="Data" row="3" column="2">7
</data>
<data name="Values" type="string" class="Data" row="3" column="3">
clarion clinton compost knox o'neill wabash webster
</data>
</row>
<row>
<header name="Class" type="string" class="RowHeader" row="4" column="1">block
</header>
<data name="Levels" type="int" class="Data" row="4" column="2">3
</data>
<data name="Values" type="string" class="Data" row="4" column="3">1 2 3
</data>
</row>
</output-body>
</output-object>
...
</branch>
</branch>
</proc>
</body>
</odsxml>
Once you have an XML file, you can go to the short tutorial for examples of what you can do with it.