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.
Hi,
I don't know if it's feasible through SAS but you could use an external xml-formatter
- Cheers -
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?
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>
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.