Sunteți pe pagina 1din 8

XML and SAS

November, 2001

XML and SAS...


An Advanced Tutorial

Greg Barnes Nelson CEO and Founder ThotWave Technologies Cary, NC Thinking Data

Introduction
Why XML?
XML is to Data like HTML is to Presentation

Benefits of this technology


XMLs markup doesnt tell us how the data should be presented, rather it tells us what it is, how it can be used its role is to describe the content, rather than how to display it.

Outline
Definitions Technology Challenges How XML Can Help Understanding What XML is (and isnt) Reading and Writing XML with SAS The Future of XML and SAS

Copyright 2001 - Greg Barnes Nelson

XML and SAS

November, 2001

XML 101
What it is
Markup language Language that helps define other languages

How is it related to SGML


Descendent of SGML (brother to HTML)

How is it related to HTML


Markup language Can be used to present information on a browser

Our first XML Document


<?xml version="1.0" ?> <customer-data> <contact-information> <cust-id>137000</cust-id> <name>Kraft, Ms. Rose</name> <gender>Female</gender> <age>34</age> <income>32,340</income> <status>Married</status> <address> <street ORDER="1">869 Veterans Blvd.</street> <street ORDER="2">Business Research</street> <city>Rutherford</city> <state>NJ</state> <zip>70702</zip> < region >NORTHEAST</region> </address> </contact-information> </customer-data>

<?xml version="1.0" ?> <customer-data>


<cust-id>137000</cust-id> <name>Kraft, Ms. Rose</na <gender>Female</gender> <age>34</age> <income>32,340</income> <status>Married</status>

</customer-data>

The Problem with HTML


<HTML> <HEAD> <TITLE>My First HTML Doc</TITLE> </HEAD> <BODY> <P><B>Hello World</B></P> </BODY> </HTML>

Copyright 2001 - Greg Barnes Nelson

XML and SAS

November, 2001

Technology Challenges
Multiple Views of the Same Data
Resume Example 1 Resume Example 2 Resume Example 3

Application Integration
Data Feeds from External Application Example

Information Optimization
Parsing large amounts of text for patterns - Example

How XML Can Help


Smart Agents
Scan data in meaningful ways parsing pages, categorizing content

Meaningful Searches
Provides context for searching

Granular Updates
Part of the XML document can be updated

Technology Optimization
XML and XSL for transformations on the fly

XML Document Rules


Beginning and ending tags must match. Elements have to be nested correctly Empty elements are signaled by either a closing tag or a />. Some reserved characters that cannot be used XML tags are case sensitive

Copyright 2001 - Greg Barnes Nelson

XML and SAS

November, 2001

Well Formed and Valid


Well Formed
<?xml version="1.0" ?> rules Follows all the <TABLE> Valid <ROW> Has a Document Type Definition <Name>Alfred</Name> <Sex>M</Sex>version="1.0" ?> <?xml <Age>14</Age> <!DOCTYPE addressbook SYSTEM class.dtd> <Height>69</Height> <TABLE> <Weight>112.5</Weight> <ROW> </ROW><Name>Alfred</Name> <Sex>M</Sex> </TABLE> <Age>14</Age> <Height>69</Height>

The Three Rs of XML


Reading Rwriting Rendering

Writing XML
A variety of tools can write XML documents The syntax is document / language specific Schemas help define the language that is generated Standards are loosely defined:
Oracle OIMDBM Doc Book

Copyright 2001 - Greg Barnes Nelson

XML and SAS

November, 2001

SAS Methods for Writing XML


Data Step/ SCL ODS Libname Engine

Data Step
Data _null_; file outxml; set sampdata.cust10 (where =(custnum=137000)) NOBS=Lst; length gender $6. marital_status $11.; addr1=htmlencode(addr1); addr2=htmlencode(addr2); if _n_=1 then do; put '<?xml version="1.0" ?>'; put '<customer-data>'; output; end; put '<cust-info>';

ODS
ods xml file="c:\xmltabulate.xml"; proc tabulate data=SASUSER.CLASS ; table ALL ,(sex age height weight) * n =' ' ; class sex age height weight; run; ods xml close;

Copyright 2001 - Greg Barnes Nelson

XML and SAS

November, 2001

Libname Statement
libname sampdata 'C:\mylib' ; libname DestXML XML 'output.xml'; data DestXML.dsetanything ; set sampdata.customer (label="My customer information"); addr1=urlencode(addr1); label custnum ="Customer-Information"; run;

Reading XML
Handled through an XML Parser
Checks for Validity and Well Formedness IBMs Java Parser Microsofts ActiveX Parser SAS Libname Engine SAS Map Tool

Rendering XML
Web Browsers Transformation Tools Style Sheets
Cascading Style Sheets - CSS eXtensible Style Language - XSL

Copyright 2001 - Greg Barnes Nelson

XML and SAS

November, 2001

Industry/ Application Adoption


Clinical Exchange (CDISC) Financial Services Customer Data Enterprise Miner Data Warehouse Administrator WAP Application Configuration

Why all the fuss?


Clear separation of data from the presentation Enables organizations to define their own language Creates an application independent exchange mechanism

Resources
Glossary Articles General XML Resources SAS Base R&D Web Site
www.sas.com/rnd/base

Copyright 2001 - Greg Barnes Nelson

XML and SAS

November, 2001

Contact Information
ThotWave Technologies
Thinking Data

Greg Barnes Nelson greg@thotwave.com ThotWave Technologies Cary, NC

Copyright 2001 - Greg Barnes Nelson

S-ar putea să vă placă și