DATA Step, Macro, Functions and more

how do I generate a correct .map for attached output file (.xml )

Accepted Solution Solved
Reply
New Contributor bwa
New Contributor
Posts: 2
Accepted Solution

how do I generate a correct .map for attached output file (.xml )

<?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;

 


Accepted Solutions
Solution
‎12-01-2016 07:37 AM
SAS Super FREQ
Posts: 8,864

Re: how do I generate a correct .map for attached output file (.xml )

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


All Replies
Solution
‎12-01-2016 07:37 AM
SAS Super FREQ
Posts: 8,864

Re: how do I generate a correct .map for attached output file (.xml )

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

 

New Contributor bwa
New Contributor
Posts: 2

Re: how do I generate a correct .map for attached output file (.xml )

Posted in reply to Cynthia_sas

Thank you Cynthia for your comments.

You made my day Robot Happy

Super User
Posts: 10,023

Re: how do I generate a correct .map for attached output file (.xml )

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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