BookmarkSubscribeRSS Feed
rnmishra
Calcite | Level 5

I am learning to import/export xml file using sas and for my learning I have manually created the data set and xml map file by copying the data and code given in the sas online documentation available here (page 59)
https://go.documentation.sas.com/api/collections/pgmsascdc/9.4_3.5/docsets/engxml/content/engxml.pdf...

I used the same code to export nhl data set using a xml map.
libname myfiles 'c:\myfiles\';
filename out 'c:\output\nhlout.xml';
libname out xmlv2 xmltype=xmlmap xmlmap='c:\example\nhlexport.map';
data out.TEAMS;
set myfiles.teams;
run;

I was expecting the same output as shown in the documentation but my output lost indentation that looks like this and every xml file record is aligned to left without showing proper 

<?xml version="1.0" encoding="utf-8" ?>
<!-- SAS XML Libname Engine (SAS92XML)
SAS XMLMap Generated Output
Version V.03.03M0P10122017
Created 2017-10-13T15:54:55
-->
<NHL description="Teams of the National Hockey League">
<CONFERENCE>Eastern
<DIVISION>Southeast
<TEAM name="Thrashers" abbrev="ATL" />
<TEAM name="Hurricanes" abbrev="CAR" />
<TEAM name="Panthers" abbrev="FLA" />
<TEAM name="Lightning" abbrev="TB" />
<TEAM name="Capitals" abbrev="WSH" />
</DIVISION>
</CONFERENCE>
<CONFERENCE>Western
<DIVISION>Pacific
<TEAM name="Stars" abbrev="DAL" />
<TEAM name="Kings" abbrev="LA" />
<TEAM name="Ducks" abbrev="ANA" />
<TEAM name="Coyotes" abbrev="PHX" />
<TEAM name="Sharks" abbrev="SJ" />
</DIVISION>
</CONFERENCE>
</NHL>
Need advice from experts here to get my indentation issue fixed.

3 REPLIES 3
Oligolas
Barite | Level 11

Hi,

I don't know if it's feasible through SAS but you could use an external xml-formatter

________________________

- Cheers -

ballardw
Super User

Please describe your indentation issue in a bit more detail. Also, if you want to post text to show the text from another file then you need to open a text box on the forum using the </> icon above the message window and paste the text into that box. The main message windows on this forum will reformat pasted text and generally remove anything that might look like "indents" and generally changes white space. The result also gets HTML tags embedded so may have other artifacts that are not actually in your text file of the XML.

 

What program did you use to look at the resulting XML?

Tom
Super User Tom
Super User

White space in XML is not significant.

<DIVISION>Southeast
<TEAM name="Thrashers" abbrev="ATL" />
<TEAM name="Hurricanes" abbrev="CAR" />
<TEAM name="Panthers" abbrev="FLA" />
<TEAM name="Lightning" abbrev="TB" />
<TEAM name="Capitals" abbrev="WSH" />
</DIVISION>

Is the exact same thing as 

<DIVISION>Southeast
  <TEAM name="Thrashers" abbrev="ATL" />
  <TEAM name="Hurricanes" abbrev="CAR" />
  <TEAM name="Panthers" abbrev="FLA" />
  <TEAM name="Lightning" abbrev="TB" />
  <TEAM name="Capitals" abbrev="WSH" />
</DIVISION>

or this

<DIVISION>Southeast<TEAM name="Thrashers" abbrev="ATL" /><TEAM name="Hurricanes" abbrev="CAR" /><TEAM name="Panthers" abbrev="FLA" /><TEAM name="Lightning" abbrev="TB" /><TEAM name="Capitals" abbrev="WSH" /></DIVISION>

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 169 views
  • 0 likes
  • 4 in conversation