UsingXML™MappertoCreateAnXMLMap Shi-Tao Yeh ...

NESUG18

Coders'Corner

Using XMLTM Mapper to Create An XML Map

Shi-Tao Yeh, GlaxoSmithKline, King of Prussia, PA.

ABSTRACT The SAS? System provides several ways to write an XML document. The users can use SAS CDISC procedure, several graphical macros, data _null_ statements, ODS XML destination, and XML Libname engine to convert SAS datasets to XML files. Some non-rectangular XML files are not directly readable from SAS XML Libname engine.

SAS Institute has added additional support and tools recently for reading and writing XML files under SAS Version 9.1.3. SAS XML Mapper is one of these tools.

SAS XML Mapper is a Java-based Graphical User Interface (GUI) application that allows users to generate an XML Map by drag-and-drop interface. XML Mapper is an XMLMap support tool to generate and modify XML Maps for use by the XML Libname engine and other vendors' applications. In addition to XML Map, SAS XML Mapper also provides SAS code sample, table view and contents. This paper illustrates how to use the XML Mapper to create an XML Map.

The SAS products used in this paper are SAS BASE? 9.1.3 and SAS/GRAPH? 9.1 on a PC Windows? platform. .

INTRODUCTION The Extensible Markup Language (XML) was developed by the World Wide Web Consortium (W3C?). It is a simple, flexible text format derived from Standard Generalized Markup Language (SGML).XML is gaining popularity in many applications among different industries.

The SAS System provides several ways to import and export XML document. The table below describes some of them.

Method Data _null_ statements

ODS

XML

destination

XML Libname

engine

XMLMapper

CDISC Procedure

Graphical macros: DS2TREE, DS2CONST

Read/Write

Write

XML

document

Write

XML

document

Read/write

XML document

Read

XML

document /write

XML map

Convert SAS

dataset to XML

document.

Write

XML

document

Description In the data step, you can use SET statement to read in the SAS dataset, use FILE statement XML output file location and use PUT statements to add the XML tags. You can use ODS XML destination to covert procedural output files to XML document. XML Libname engine is for import, export XML document. It also allows user to create XML Map. XMLMapper can open XML file, XML Map, and XML Schema. It can create XML Map, SAS Sample code, table view, and contents. The procedure follows CDISC SDS 3.1 and ODM 1.2 standards to convert SAS dataset to XML document for submission. The macros provide options for user to create external XML file.

Table 1. Ways to Read and Write XML Document in the SAS System

The following sample code utilizes ODS XML destination to create an XML document.

1

NESUG18

libname sb 'c:\xml'; ods xml file='c:\xml\xmlae01.xml'; title 'Listing of Adverse Events'; data f1;

set sb.ae; Keep pid rand body1 pref ; proc print data=f1(obs=20);run; ods xml close; run;

Coders'Corner

Figure 1. XML Document Created from ODS Facility

The following example use SAS macro DS2TREE to create an XML document. DS2TREE macro provides arguments of xmltype, makexml, xmlurl, and xmlfile for users to specify the external XML file to be created with the XML file location.

ods listing; %ds2tree(ndata=final,

codebase=:\xml, htmlfile=c:\xml\g9aetr08.htm, xmltype=external, makexml=y, xmlurl=:\xml, xmlfile=c:\xml\g9aetr08.xml, nid=apref_c, nparent=abody1_c, nlabel=pref, ntip=pref1,

2

NESUG18

nfntname=tname, nfntstyl=fnwt, ncolor=apref_c, ncolfmt=$body., height=500, width=980, lwidth=lscount, lcolor=lscount, lcolfmt=lcola., cback=cxbbffff, cnode=yellow, cselect=red, bg=cxffaaff, bgtype=color, ttag=header 3, tcolor=navy, ftag=header 5, fcolor=navy); run; ods _all_ close; run;

Coders'Corner

Figure 2. XML Document Created from SAS %DS2TREE Macro

XML MAPPER An XML document needs to combine an XML Schema to allow machines to carry out rules defined in the schema. XML Schemas are the languages which provide a means for defining the data structure, content, shared vocabularies, and semantics of XML documents. An XML map is a set of instructions or definitions of the data structure on how to convert XML data to a specific data or database format.

The SAS XML Libname can only read in XML files with file structure in a rectangular manner to SAS. The SAS XML Libname engine shipped with SAS 8.2 can not handle non-rectangular input file. SAS 9.1.3 includes a production version of the XML Mapper for users to create XML Map. SAS XML Mapper is a Java-based Graphical User Interface (GUI) application that allows users to generate an XML Map by drag-and-drop interface. XML Mapper is an XMLMap support tool to generate and modify XML Maps for use by the XML engine and other vendors' applications. In addition to XML Map, SAS XML Mapper also provides SAS code sample, table view and contents. The following sections illustrate step by step usage of XML Mapper.

3

NESUG18

GETTING STARTED WITH XML MAPPER Step 1: Select ALL Programs from the Start button in Windows. Step 2: Select SAS, click SAS XML Mapper to launch the application.

Coders'Corner

Figure 3. Launch the SAS XML Mapper Application

The XML Mapper consists of 3 panes. The top-left pane is named the XML Pane and displays the tree structure of an XML file. The top-right pane is named XML Map Pane and displays a graphical representation of the table and columns specified for the target SAS dataset(s). It also allows the user to specify the properties and formats of each dataset column. The bottom pane is named the Source Pane. It includes multiple buttons which in turn display the XML document source code, the XML Map code, the automatically generated SAS code used to read the XML file, table view button, a validation test button, and a Log file. Figure 4 illustrates the XML Mapper environment.

Figure 4. The SAS XML Mapper Environment

OPENING AN XML DOCUMENT Step 3: Select Open XML from the File menu.

4

NESUG18

Coders'Corner

Figure 5. Opening An XML Document Step 4: Select File Name to Open XML document.

Figure 6. Select XML File Name to Open The selected XML file is displaying in Figure 7. The XML Pane in Figure 7 displays a tree view of the XML document. The Source Pane displays the text of the XML document while the XML Map Pane is initially empty.

5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches