BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bwa
Calcite | Level 5 bwa
Calcite | Level 5
<?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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
Diamond | Level 26

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

read_xml.png

 

View solution in original post

3 REPLIES 3
Cynthia_sas
Diamond | Level 26

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

read_xml.png

 

bwa
Calcite | Level 5 bwa
Calcite | Level 5

Thank you Cynthia for your comments.

You made my day Robot Happy

Ksharp
Super User
Your XML doesn't look too difficult.
Maybe you could use DATA STEP to get it directly .

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1535 views
  • 1 like
  • 3 in conversation