<?xml version="1.0" encoding="UTF-8"?> <Test> <Set> <Header> <dataset formaat="v1" status="production" naam="needthisoutputfromsas.xml"/> <date>12-10-2016</date> <source>mycompany</source> </Header> <Record> <Birthdate pattern="dd-MM-yyyy">21-10-1945</Birthdate> <Gender>V</Gender> <Postalcode>1234</Postalcode> <Data> <Key>1</Key> </Data> </Record> <Record> <Birthdate pattern="dd-MM-yyyy">11-02-1963</Birthdate> <Gender>V</Gender> <Postalcode>4321</Postalcode> <Data> <Key>2</Key> </Data> </Record> <Record> <Birthdate pattern="dd-MM-yyyy">26-05-1978</Birthdate> <Gender>V</Gender> <Postalcode>2345</Postalcode> <Data> <Key>3</Key> </Data> </Record> </Set> </Test>
Hello,
I hope someone can help me generating a correct .map for export my sas dataset into the above.xml example. The auto_gen function in sas XML mapper makes all these tables, but I can ouput only one, right?
<?xml version="1.0" encoding="UTF-8"?>
<!-- ############################################################ -->
<!-- 2016-11-29T21:53:10 -->
<!-- SAS XML Libname Engine Map -->
<!-- Generated by XML Mapper, 904000.0.0.20130522190000_v940 -->
<!-- ############################################################ -->
<!-- ### Validation report ### -->
<!-- ############################################################ -->
<!-- XMLMap validation completed successfully. -->
<!-- ############################################################ -->
<SXLEMAP name="Test" version="2.1">
<!-- ############################################################ -->
<OUTPUT>
<HEADING>
<ATTRIBUTE name="description" value=""/>
</HEADING>
<TABLEREF name="Record"/>
</OUTPUT>
<NAMESPACES count="0"/>
<!-- ############################################################ -->
<TABLE name="Record">
<TABLE-PATH syntax="XPath">/Test/Set/Record</TABLE-PATH>
<COLUMN name="Birthdate">
<PATH syntax="XPath">/Test/Set/Record/Birthdate</PATH>
<TYPE>numeric</TYPE>
<DATATYPE>date</DATATYPE>
<FORMAT width="10">IS8601DA</FORMAT>
<INFORMAT width="10">IS8601DA</INFORMAT>
</COLUMN>
<COLUMN name="Gender">
<PATH syntax="XPath">/Test/Set/Record/Gender</PATH>
<TYPE>character</TYPE>
<DATATYPE>string</DATATYPE>
<LENGTH>1</LENGTH>
</COLUMN>
<COLUMN name="Postalcode">
<PATH syntax="XPath">/Test/Set/Record/Postalcode</PATH>
<TYPE>numeric</TYPE>
<DATATYPE>integer</DATATYPE>
</COLUMN>
<COLUMN name="Key">
<PATH syntax="XPath">/Test/Set/Record/Data/Key</PATH>
<TYPE>numeric</TYPE>
<DATATYPE>integer</DATATYPE>
</COLUMN>
</TABLE>
</SXLEMAP>
Thanks in advance,
Brendy Wauben
/********************************************************************************
* Generated by XML Mapper, 904000.0.0.20130522190000_v940
********************************************************************************/
filename client 'C:\mysas\needthisoutputfromsas.xml';
filename SXLEMAP 'C:\mysas\out.map';
libname client xmlv2 xmlmap=SXLEMAP ;*access=READONLY;
libname out "C:\mysas\out";
* local files;
data client.Record;
set out.mydataset ;
run;
Hi:
I suspect one of your issues will come from the DATE INFORMAT. If you look here, http://support.sas.com/techsup/notes/v8/11/206.html the IS8601DA informat is expecting year to be first. So I would change that to ddmmyy or anydtdte for the informat (and probably the format too.)
Also, if you are READING the XML and importing it into a SAS dataset, I would expect to see this on the set:
set client.record; for the INPUT, as shown below.
I did have to change the INFORMAT and also changed the FORMAT for the date field.
cynthia
Hi:
I suspect one of your issues will come from the DATE INFORMAT. If you look here, http://support.sas.com/techsup/notes/v8/11/206.html the IS8601DA informat is expecting year to be first. So I would change that to ddmmyy or anydtdte for the informat (and probably the format too.)
Also, if you are READING the XML and importing it into a SAS dataset, I would expect to see this on the set:
set client.record; for the INPUT, as shown below.
I did have to change the INFORMAT and also changed the FORMAT for the date field.
cynthia
Thank you Cynthia for your comments.
You made my day ![]()
Your XML doesn't look too difficult. Maybe you could use DATA STEP to get it directly .
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.