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
SAS Super FREQ

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
SAS Super FREQ

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 .

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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