READING AND WRITING XML FILES FROM SAS Miriam Cisternas, MGC Data Services, Carlsbad, CA Ricardo Cisternas, MGC Data Services, Carlsbad, CA



Similar documents
Import and Output XML Files with SAS Yi Zhao Merck Sharp & Dohme Corp, Upper Gwynedd, Pennsylvania

HP Quality Center. Software Version: Microsoft Excel Add-in Guide

HP Quality Center. Software Version: Microsoft Excel Add-in Guide

Essential Project Management Reports in Clinical Development Nalin Tikoo, BioMarin Pharmaceutical Inc., Novato, CA

Qlik REST Connector Installation and User Guide

HP Application Lifecycle Management

StreamServe Persuasion SP4 StreamServe Connect for SAP - Business Processes

Switching from PC SAS to SAS Enterprise Guide Zhengxin (Cindy) Yang, inventiv Health Clinical, Princeton, NJ

Importing Excel Files Into SAS Using DDE Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA

PharmaSUG Paper QT26

Ross Video Limited. DashBoard Server and User Rights Management User Manual

SAS Business Data Network 3.1

Using the SAS Enterprise Guide (Version 4.2)

How to Create an XML Map with the XML Mapper

XSLT Mapping in SAP PI 7.1

Reading Delimited Text Files into SAS 9 TS-673

Tips and Tricks for Creating Multi-Sheet Microsoft Excel Workbooks the Easy Way with SAS. Vincent DelGobbo, SAS Institute Inc.

Importing from Tab-Delimited Files

Witango Application Server 6. Installation Guide for Windows

About XML in InDesign

HP Quality Center. Software Version: Microsoft Word Add-in Guide

DocumentsCorePack for MS CRM 2011 Implementation Guide

Scribe Online Integration Services (IS) Tutorial

Chapter 2 The Data Table. Chapter Table of Contents

XML for SAS Programmers

Ultimus and Microsoft Active Directory

Microsoft Office. Mail Merge in Microsoft Word

EMC SourceOne Auditing and Reporting Version 7.0

3 IDE (Integrated Development Environment)

isupport 15 Release Notes

User s Guide for the Texas Assessment Management System

IBM Unica emessage Version 8 Release 6 February 13, User's Guide

Leveraging the SAS Open Metadata Architecture Ray Helm & Yolanda Howard, University of Kansas, Lawrence, KS

SmartLink for Lotus Notes User Guide

You have got SASMAIL!

Programming Tricks For Reducing Storage And Work Space Curtis A. Smith, Defense Contract Audit Agency, La Mirada, CA.

Let SAS Modify Your Excel File Nelson Lee, Genentech, South San Francisco, CA

DocuSign Quick Start Guide. Using the Bulk Recipient Feature. Overview. Table of Contents

HP Enterprise Integration module for SAP applications

Technical Paper. Reading Delimited Text Files into SAS 9

metaengine DataConnect For SharePoint 2007 Configuration Guide

Sage 200 Web Time & Expenses Guide

State of Michigan Data Exchange Gateway. Web-Interface Users Guide

Importing and Exporting With SPSS for Windows 17 TUT 117

SAS Enterprise Guide A Quick Overview of Developing, Creating, and Successfully Delivering a Simple Project

Data Tool Platform SQL Development Tools

Behavioral Health System

OnDemand for Academics

DiskPulse DISK CHANGE MONITOR

WebSpy Vantage Ultimate 2.2 Web Module Administrators Guide

ADP Workforce Now V3.0

Exchanger XML Editor - Canonicalization and XML Digital Signatures

Extensible Markup Language (XML): Essentials for Climatologists

Forms Printer User Guide

Chapter 19: XML. Working with XML. About XML

Choosing the Best Method to Create an Excel Report Romain Miralles, Clinovo, Sunnyvale, CA

Introduction to XML Applications

Copyright 2015 SolarWinds Worldwide, LLC. All rights reserved worldwide. No part of this document may be reproduced by any means nor modified,

ABSTRACT INTRODUCTION

HP Application Lifecycle Management

Sage CRM. Sage CRM 2016 R1 Mail Merge Datasheet

DBF Chapter. Note to UNIX and OS/390 Users. Import/Export Facility CHAPTER 7

Preserving Line Breaks When Exporting to Excel Nelson Lee, Genentech, South San Francisco, CA

Access Tutorial 1 Creating a Database

PharmaSUG Paper CC30

ODS for PRINT, REPORT and TABULATE

How To Write A File System On A Microsoft Office (Windows) (Windows 2.3) (For Windows 2) (Minorode) (Orchestra) (Powerpoint) (Xls) (

Appointments Module. User s Manual

OneTouch 4.0 with OmniPage OCR Features. Mini Guide

Using EMC Documentum with Adobe LiveCycle ES

Advanced LED Controller (LED Chaser)

Teradata SQL Assistant Version 13.0 (.Net) Enhancements and Differences. Mike Dempsey

Excel To Component Interface Utility

LATITUDE Patient Management System

Introduction. Why Use ODBC? Setting Up an ODBC Data Source. Stat/Math - Getting Started Using ODBC with SAS and SPSS

Payroll Import. Version Main screen for Payroll Import.

LabVIEW Internet Toolkit User Guide

SAS Activity-Based Management Server Software Release 6.0 for Windows

Upgrade: SAP Mobile Platform Server for Windows SAP Mobile Platform 3.0 SP02

A Method for Cleaning Clinical Trial Analysis Data Sets

Getting started with the Asset Import Converter. Overview. Resources to help you

Using Macros to Automate SAS Processing Kari Richardson, SAS Institute, Cary, NC Eric Rossland, SAS Institute, Dallas, TX

SES Project v 9.0 SES/CAESAR QUERY TOOL. Running and Editing Queries. PS Query

Customized Excel Output Using the Excel Libname Harry Droogendyk, Stratia Consulting Inc., Lynden, ON

My IC Customizer: Descriptors of Skins and Webapps for third party User Guide

Workplace Giving Guide

Creating Raw Data Files Using SAS. Transcript

versasrs HelpDesk quality of service

SalesPad for Dynamics GP DataCollection Installation & Setup

Practice Fusion API Client Installation Guide for Windows

Manual POLICY PATROL SIGNATURES FOR OUTLOOK, GOOGLE APPS & OFFICE 365

Basic Website Maintenance Tutorial*

Customer admin guide. UC Management Centre

Adobe Conversion Settings in Word. Section 508: Why comply?

Methodologies for Converting Microsoft Excel Spreadsheets to SAS datasets

Paper Hot Links: Creating Embedded URLs using ODS Jonathan Squire, C 2 RA (Cambridge Clinical Research Associates), Andover, MA

Transcription:

READING AND WRITING XML FILES FROM SAS Miriam Cisternas, MGC Data Services, Carlsbad, CA Ricardo Cisternas, MGC Data Services, Carlsbad, CA ABSTRACT XML (extensible Markup Language) is gaining popularity as a medium for data exchange. SAS Institute has added additional support recently for reading and writing XML files under both 8.2 and 9.0. The purpose of this workshop is to provide a quick introduction to XML, show the ways in which XML is read and written from SAS, and then present hands-on examples for reading in and mapping XML files to SAS datasets and writing out SAS datasets to XML files. INTRODUCTION This Hands-On Workshop is targeted toward SAS programmers with a working knowledge of BASE SAS and familiarity with HTML or another markup language. This workshop will guide you through a series of examples that illustrate how to read and write XML files from SAS, on computers running SAS 8.2 configured to use an interim re-release of the SAS XML libname (from July 2002). THE CHALLENGE XML is a language that is hierarchical and describes data in terms of markup tags. But SAS is usually implemented using more of a relational model, even though data sets are often not fully normalized. So translation between these two formats requires at least a rudimentary understanding of the structure behind the data. Figure 1 illustrates a possible XML representation of some clinical trial specimen data. In this case, all clinical trial data is grouped under a single study which is identified by a StudyID. A study may have multiple sites from where data is collected and each site is identified by a unique SiteID. A site has multiple participants who may visit the site on multiple individual visits. Each visit has a date and VisitID and may include the collection of specimens. In turn, each specimen has a type and it is collected in one or more tubes, all of which share the same tube type. the names of the tables can be extracted by determining the critical path among the nodes of the tree in Figure 1. At each level of the tree, there is a single node that acts as a root for a sub-tree (i.e. Study, Site). Each one of these critical path nodes becomes a table in the relational diagram while the rest of the nodes become column names within the table named after its parent node. In particular, some of these subordinate nodes become primary keys within their tables if they can uniquely identify a table entry. For instance, the table Site uses the column SiteID as a primary key since it is a unique identifier for all site records. The primary keys are also reproduced in related tables as foreign keys to establish relationships among tables. For example, SiteID is the primary key to the Site table and it is also a foreign key within the Participant table reflecting the relationship among Site and Participant. Additionally, the links among the tables preserve the cardinality of the relationships. Figure 2 Transferring data from a hierarchical structure (XML) to a relational structure (SAS) is a non-trivial problem. It requires good understanding of the data to be able to identify primary keys, foreign keys, and dataset variables. Data transfer from a relational structure (SAS) to a hierarchical structure (XML) is also difficult. You need to identify which data elements take precedence in the hierarchy and establish an order relationship. In either case, the programmer must have a solid understanding of the source data to be transferred. Figure 1 Figure 2 diagrams a possible relational view of the same data displayed in Figure 1. The relational diagram stores the same information as the hierarchical diagram in Figure 1 preserving both the data and the relationships between the data entities. In this case, BASIC RULES OF XML The basic building block of XML is an element. Elements begin with an open tag <element_name> Elements can either: end with an end tag </element_name> or terminate with /> in their open tag <element_name/>

All tags must be fully nested no overlapping tag boundaries are allowed. A tag may optionally include a value. A tag may optionally include attributes, which are values enclosed in double quotes. A comment is text delimited by <!-- and -->. ACTIVITY 1: VIEWING AN XML FILE FROM INTERNET EXPLORER Since XML documents are text files, they can be viewed in virtually any text editor. In addition, there are XML editors available that simplify the process of writing and editing XML documents are related files (see the References section at the end of this paper for details). But even using Microsoft s Internet Explorer to view an XML file can provide us valuable information about its structure that we cannot see in a simple text editor such as NotePad. Consider the XML document displayed in the box below: <!DOCTYPE client_list SYSTEM "C:\workshop\XML\client_list.dtd"> <client_list> <client status="active"> <name>john Doe</name> <address>1212 Maple Road</address> <city>springfield</city> <zip>91234</zip> <client status="inactive"> <name>mary Doe</name> <address>1212 Maple Road</address> <city>springfield</city> <zip>91234</zip> <client status="active"> <name>john Public</name> <address>100 Byron Road</address> <city>carlsbad</city> <zip>99999</zip> <client status="active"> <name>fionnula Jackson</name> <address>444 First Street</address> <city>san Mateo</city> <zip>94402</zip> </client_list> If the file containing the statements in the box above is named C:\workshop\XML client_list.xml, you can bring the file into Internet Explorer as follows: From Windows Explorer or My Computer, navigate to the C:\workshop\XML subdirectory. Right-click on client_list.xml. Select Open With and then Internet Explorer Your file should be displayed similarly to the screen shot provided in Figure 3. Figure 3 Internet Explorer displays XML in a tree view where each parent node is preceded by a control (a plus or minus sign) that allows the user to collapse or expand a sub-tree of nodes. It also color codes the display of elements and attributes (maroon), data (black), triangular brackets (blue), directives (blue), and comment text (grey). ACTIVITY 2: READING AN XML DOCUMENT INTO A SAS DATASET The easy way is to access and write XML from SAS is use the XML engine on a libname statement (versions 8.1 and above). However, using this statement without any other options requires that the XML file structure contain only rectangular datasets (i.e., hierarchical data are not supported). For this activity, we use the XML engine to parse the incoming file called hosp_discharge.xml, which contains an excerpt of a hospital discharge data file. The syntax of the XML libname is similar to that of a standard SAS libname, but: xml is placed after the libname keyword and before the location to indicate that the XML engine is to be used. The location in quotes refers to the specific XML file, not just a directory path. Before reading in an XML file into SAS, it is a good idea to examine it. Figure 4 shows a screenshot of the hosp_discharge.xml file in Internet Explorer. The file contains a root-level node called <hosp_discharge> which in turn contains a number of <discharge> elements. Each <discharge> element has 5 children elements <patient_id>, <SEX>, <admit_date>, <DOB>, and <discharge_date>.

characters in a name to upper case. Finally, the XML engine transforms dates in yyyy-mm-dd format to character variables. If we require SAS date equivalents we must either: use XMLMAP (described in activities 5 and 6 below). do post processing of the date variables in SAS. ACTIVITY 3: CONVERTING A SAS DATASET TO XML To convert a SAS dataset to XML, create an XML libname and then write to it. The following lines of code illustrate how to write out the dataset created in activity #2. The program adds in a SAS date variable, xfer_date, to record the date we transferred the file back to XML format. title1 'XML WORKSHOP EXERCISE #3'; libname out xml 'C:\workshop\XML\discharge_from_SAS.xml'; Figure 4: The code to read the XML file is as follows: title1 'XML WORKSHOP EXERCISE #2'; libname in xml 'C:\workshop\XML\hosp_discharge.xml'; data discharge; set in.discharge; title2 'check parsing of file'; proc print data=discharge; proc contents data=discharge; The PROC PRINT of the resulting SAS dataset is reproduced below: DISCHARGE_ PATIENT_ DATE DOB ADMIT_DATE SEX ID 2000-03-24 1940-12-27 2000-03-24 F 2121229 2000-03-30 1946-08-25 2000-03-29 F 3359900 2000-03-05 1910-06-30 2000-03-03 M 4245123 2000-03-28 1946-06-13 2000-03-25 M 6919113 2000-03-01 1941-02-01 2000-02-25 F 2836181 2000-12-22 1928-11-25 2000-12-20 M 7098312 2000-03-27 1922-09-10 2000-03-26 M 9983225 2000-03-09 1916-08-31 2000-03-09 F 1299349 2000-03-27 1946-06-05 2000-03-26 M 555856 An excerpt from the PROC CONTENTS is below: # Variable Type Len Pos Format Informat --------------------------------------------------- 3 ADMIT_DATE Char 10 28 $10. $10. 1 DISCHARGE_DATE Char 10 8 $10. $10. 2 DOB Char 10 18 $10. $10. 5 PATIENT_ID Num 8 0 BEST8. BEST8. 4 SEX Char 1 38 $1. $1. If we examine the SAS code and the XML file in Figure 4 we can notice that the name of the SAS dataset is the same as the name of the second-level element in the XML file (<discharge>). Additionally, the variable names in the PROC PRINT output match the name of the third-level child elements in the XML file but the case of the element names is not preserved, as SAS converts all data out.discharge; set discharge; ***let s add in the date converted as ***today s date and format it in ISO8601 ***(yyyy-mm-dd) format; xfer_date=today(); format xfer_date is8601da10.; The resulting XML file as seen through Internet Explorer (partially collapsed) is displayed in Figure 5, below. There are some things to notice about the resulting XML file in Figure 5: The root element is <TABLE>. This is a convention SAS uses when writing out XML files using the XML libname engine. Tags for all the original fields are all caps (this conversion was done during the original parsing in Activity #2). The tags for the xfer_date field are in lower case, since we created that variable using lower case in SAS. The xfer_date field in SAS internal numeric data storage (# of days since January 1, 1960. This is because formats are not preserved when copying to non-native engines such as XML. In fact, your SAS log should show the following note: NOTE: SAS variable labels, formats, and lengths are not written to DBMS tables. The solution to this problem is to use the PUT function to convert this field to a character equivalent. Please note that the default behaviors of the XML engine have been changing with successive re-releases. Test your code carefully when reading/writing XML files in a production environment.

ACTIVITY 5: READING IN MORE COMPLICATED XML FILES As mentioned earlier, using the XML libname to read in XML files to SAS requires that the input file be structured in a rectangular (non hierarchical) manner. Specifically, this means that each observation to be read into SAS must be a second-level element, and each variable value must appear as a third-level element. By default, XML attributes are dropped in the conversion process, and SAS determines the data type, format, and informat of all variables. The SAS XML libname engine shipped with SAS 8.2 cannot handle more complicated input files. For the purposes of this workshop, the computer you are using has been upgraded to the July 2002 re-release provided to the authors by SAS Institute. The re-release includes the XMLMAP option, which can read in XML files that don t map directly to rectangular data. An updated rerelease is expected soon. As of the time of this writing, the most current release available for the SAS XML Libname engine on the SAS website can be downloaded from: http://www.sas.com/apps/demosdownloads/xmlengine_ex P_sysdep.jsp?packageID=000198 Figure 5 ACTIVITY 4: CREATING XML FILES FROM SAS PROCS USING ODS ODS can render output in a number of different formats such as listing, html, and rtf. One of the output destinations is XML. Following is code to render a PROC PRINT of the discharge data to an XML file. ods xml file='c:\workshop\xml\discharge_print.xml'; proc print noobs data=discharge; ods xml close; If you examine the resulting file, discharge_print.xml in IE, you will notice that it follows a very rigid data structure that specifies every detail of the PROC PRINT issued including the title, the name of the data set, the descriptions of every column, and the data of the entire table on a row by row basis. This XML format carries a lot of detail which is unrelated to the data being presented making it impractical as a data transport mechanism because it is too verbose making the XML files too large. Using the XMLMAP Option Requires the Creation of a Map File The map file is an XML file that specifies how SAS is to map the XML document to specific datasets, variables and observations. Documentation for this option can be found at http://support.sas.com/rnd/base/topics/sxle82/exp82/mapx mlexp.html. See also Anthony Friebel s paper presented at SUGI 28 which includes an extensive discussion of the XMLMAP engine (in the References section below). For this workshop, we use XMLMAP v1.0 syntax. The structure of the basic XMLMAP objects is displayed in Figure 6. The root element of the XMLMAP file is the SXLEMAP element. It can have one or more TABLE children elements. Each TABLE element identifies a SAS dataset by name using the name attribute. A TABLE element has a single TABLE_XPATH child element which specifies the point in the XML document where the table data begins. A TABLE element also has one or more COLUMN elements that identify the columns of the dataset. A COLUMN element will have several children: a DATATYPE element that specifies the XML data type of the source data an optional FORMAT element that specifies a format to be associated with the variable an optional INFORMAT element that specifies an informat to be associated with the variable a LENGTH element that specifies the data length a TYPE element that indicates the SAS data type (character or numeric) used for the column an XPATH element that specifies where to look for column data within the XML input file s hierarchy Figure 6

The structure of the XMLMAP file is fairly complex. Fortunately, SAS 9 includes a point-and-click interface (Atlas) that generates the XMLMAP file. Syntax for Using the XMLMAP option on the XML Libname Statement libname example xml '<path/filename>' xmlmap= '<path/filename>.map'; The Exercise Use XMLMAP to read all client_list.xml elements and 1) map the status= attribute to a character variable named status and 2) map zipcode to a character variable In general, we accomplish this using a three-step process Step 1: View the Data/Understand the structure. Step 2: Decide what you want to extract. Step 3: Create the map file. Creating the Map File If you do not have access to the SAS 9 Atlas tool, it is helpful to create a worksheet containing information about the elements that you will include in the map file. A partially complete example appears below: Table Information Name= TABLE_XPATH client /client_list/client Column Information NAME= XPATH TYPE DATA TYPE status /client_list/client/@status char string 8 name /client_list/client/name char string 16 address city state /client_list/client/address zip char string Then, you can start creating the map file by creating a skeleton file. You can use either the SAS editor or WordPad to type in the following: <?xml version="1.0"?> <SXLEMAP VERSION="1.0"> <TABLE name= client"> <TABLE_XPATH>/client_list/client </TABLE_XPATH> <COLUMN name="status"> <XPATH>/client_list/client/@status</XPATH> <LENGTH>8</LENGTH> You will insert more information for the remaining variables here </TABLE> </SXLEMAP> LENGTH Then fill in with the columns you documented in the previous worksheet. The completed map file appears below: <?xml version="1.0"?> <SXLEMAP VERSION="1.0"> <TABLE name="client"> <TABLE_XPATH>/client_list/client </TABLE_XPATH> <COLUMN name="status"> <XPATH>/client_list/client/@status</XPATH> <LENGTH>8</LENGTH> <COLUMN name="name"> <XPATH>/client_list/client/name</XPATH> <LENGTH>16</LENGTH> <COLUMN name="address"> <XPATH>/client_list/client/address</XPATH> <LENGTH>16</LENGTH> <COLUMN name="city"> <XPATH>/client_list/client/city</XPATH> <LENGTH>11</LENGTH> <COLUMN name="state"> <XPATH>/client_list/client/state</XPATH> <LENGTH>2</LENGTH> <COLUMN name="zip"> <XPATH>/client_list/client/zip</XPATH> <LENGTH>5</LENGTH> </TABLE> </SXLEMAP> Putting it All Together So now you are ready to write the SAS code that will read in the file and reference the XMLMAP file. As is the case with any file conversion, it is a good idea to include a PROC PRINT and PROC CONTENTS to check your work, as follows: filename map 'C:\workshop\XML\client_list10.map'; libname c_list xml 'C:\workshop\XML\client_list.xml' xmlmap=map; proc contents data=c_list._all_; proc print data=c_list.client; The Result of Your Efforts An excerpt from PROC CONTENTS on the converted file appears below: # Variable Type Len Pos Format Informat

--------------------------------------------------- 3 address Char 16 24 $16. $16. 4 city Char 11 40 $11. $11. 2 name Char 16 8 $16. $16. 5 state Char 2 56 $2. $2. 1 status Char 8 0 $8. $8. 6 zip Char 5 64 $5. $5. ACTIVITY 6 (EXTRA CREDIT) In this activity, we will go through the process of reading a complex XML file in more detail. The first step is to look at the input data to learn about its structure. If you examine the file acc.xml (see Figure 7) you will see that it contains lab data for a clinical trial. There is a root element called <study> that contains a variable number of children members called <participant> which in turn can have multiple children called <visit>. Figure 9 For the second task, assume that we want to extract the data from the following elements into one dataset: study_id, site_id, participant_id, collection_date, collection_time, visit_num, barcode_id_9, tube_type, and num_tubes. Build a worksheet to organize the data needed to refer to the fields in an XMLMAP file. NAME= RETAIN= XPATH TYPE* DATATYPE LENGTH FORMAT INFORMAT study_id YES C STRING 5 site_id YES C STRING 5 participant_id YES N INT 3 Z3.0 collection_date YES N STRING 10 yymmdd10. collection_time YES N STRING 8 time8. visit_num YES N STRING 2 "barcode_id_9" C STRING 9 "tube_type" C STRING 25 "num_tubes" N INT 2 Figure 7 The first task in this activity is to determine the names of the elements in the XML file that complete the hierarchical structure of elements illustrated in Figure 8. *C=CHARACTER N=NUMERIC Complete the worksheet filling in all the XPATH cells. Notice how all the fields above barcode_id_9 in the hierarchy have RETAIN= yes. This is so that those fields will retain their values when new specimen elements are encountered. Using the information from the worksheet, create the XMLMAP file acc10.map. An excerpt of the completed XMLMAP file follows: Figure8 The resulting completed diagram can be seen in Figure 9. <?xml version="1.0"?> <!-- MAP file to create flat SAS file from acc.xml created by Miriam G Cisternas (MGC Data Services) --> <SXLEMAP VERSION="1.0"> <TABLE name="acc"> <!-- The following statement ensures that a new observation is created every time a new specimen tag is encountered --> <TABLE_XPATH> /acc/study/participant/visit/specimen </TABLE_XPATH>

<COLUMN name="study_id" RETAIN="YES"> <XPATH>/acc/study/study_ID</XPATH> <LENGTH>5</LENGTH> <COLUMN name="site_id" RETAIN="YES"> <XPATH>/acc/study/participant/site_ID</XPATH> <LENGTH>5</LENGTH> <COLUMN name="participant_id" RETAIN="YES"> <XPATH>/acc/study/participant/participant_ID</XPATH> <FORMAT WIDTH="3" NDEC="0">z</FORMAT> <DATATYPE>INT</DATATYPE> <LENGTH>3</LENGTH>... defections for the rest of the columns... </TABLE> </SXLEMAP> Finally, write the code to associate the input file to the map file and create a temporary dataset. Do a print and contents to verify that things worked correctly. The resulting program is as follows: ***importing to SAS from XML using an XMLMAP *** (v 1.0 syntax) to read in a hierarchical file; filename map 'C:\workshop\XML\acc10.map'; libname acc xml 'C:\workshop\XML\acc.xml' xmlmap=map; Other brand or product names are registered trademarks or trademarks of their respective companies. REFERENCES Castro, Elizabeth. XML for the World Wide Web. Peachpit Press: Berkeley, CA. 2001. Friebel, Anthony. <XML> at SAS A More Capable XML Libname Engine. Paper 179-27. SUGI 27 Proceedings. SAS: Cary, NC. 2002. Friebel, Anthony. XML? We do that!. Paper 173-28. SUGI 28 Proceedings. SAS: Cary, NC. 2003. How to Successfully Import XML Using the Enhanced SAS XML LIBNAME Engine, SAS: Cary, NC. 2002. http://www.sas.com/rnd/base/topics/sxle82/exp82/mapxmle xp.html Using ODS to Export Markup Languages SAS: Cary, NC 2002. http://www.sas.com/rnd/base/topics/odsmarkup/index.html XML Spy is available from: www.xmlspy.com. XML Edit Pro, a shareware XML editor, is available from www.daveswebsite.com CONTACT INFORMATION Your comments and questions are valued and encouraged. Contact the authors at: MGC Data Services 5051 Millay Court Carlsbad, CA 92008 (760) 804-5746 miriam@mgcdata.com ricardo@mgcdata.com www.mgcdata.com proc contents data=acc.acc; proc print data=acc.acc; proc copy in=acc out=work; CONCLUSIONS This hand on workshop has presented the basic processes for reading and writing XML data to and from SAS. SAS offers several ways to handle XML files depending on the structure of the XML data. If the data comes in a rectangular format, XML libname can process it. If the XML data has a complex hierarchical structure, you will need to specify what fields to extract and where to find them using an XMLMAP file. The files discussed in this paper will be available for download after the conference from the following URL: http://www.mgcdata.com/presentations/xmlsashandson.zip COPYRIGHT INFORMATION SAS is a registered trademark of SAS Institute, Inc. in the USA and other countries. Indicates USA registration.