| Return to previous page
|
First, here is the XML document:
<?xml version="1.0" ?> <Root> <ISODATE> <BASIC>20010911</BASIC> <EXTENDED>2001-09-11</EXTENDED> </ISODATE> </Root>
The following XMLMap imports the XML document using the SAS informats and formats to read and write the date values:
<?xml version="1.0" encoding="UTF-8"?> <SXLEMAP version="1.2" name="ISOdate" description="Reading a Basic and Extended format ISO date field"> <!-- ############################################################ --> <TABLE name="ISODATE"> <TABLE-PATH syntax="XPath">/Root/ISODATE</TABLE-PATH> <COLUMN name="BASIC"> <PATH syntax="XPath">/Root/ISODATE/BASIC</PATH> <TYPE>numeric</TYPE> <DATATYPE>date</DATATYPE> <FORMAT width="10">IS8601DA</FORMAT> <INFORMAT width="8">ND8601DA</INFORMAT> </COLUMN> <COLUMN name="EXTENDED"> <PATH syntax="XPath">/Root/ISODATE/EXTENDED</PATH> <TYPE>numeric</TYPE> <DATATYPE>date</DATATYPE> <FORMAT>IS8601DA</FORMAT> <INFORMAT>IS8601DA</INFORMAT> </COLUMN> </TABLE> </SXLEMAP>
The following explains the XMLMap syntax that imports the date values:
For the Basic variable:
the INFORMAT element specifies the ND8601DA SAS informat, which reads date values into a variable in the basic format YYYYMMDD.
Note: As recommended, when you read values into a variable with a basic format SAS informat, this example writes the values with the corresponding extended format SAS format.
For the Extended variable:
For the Extended variable, the INFORMAT element specifies the IS8601DA SAS informat, which reads date values into a variable in the basic format YYYY-MM-DD.
The following SAS statements import the XML document and display PRINT procedure output:
filename dates 'c:\My Documents\XML\ISOdate.xml'; filename map 'c:\My Documents\XML\ISOdate.map'; libname dates xml xmlmap=map; proc print data=dates.isodate; run;
PRINT Procedure Output for Imported Data Set DATES.ISODATE
The SAS System 1
Obs BASIC EXTENDED
1 2001-09-11 2001-09-11