<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Pulling out tag info from xml file in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Pulling-out-tag-info-from-xml-file/m-p/109755#M30503</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an xml file that was sent to me from an outside source.&amp;nbsp; What I need to do it parse it so I have all the tag and property info put into a table.&lt;/P&gt;&lt;P&gt;I have tried importing it as an xml file but the file isn't formatted correctly.&amp;nbsp; I have no say in how the file comes to me so I decided to import the file and pull the info out myself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is just a small example of some of the stuff within the file.&lt;/P&gt;&lt;P&gt;&amp;lt;prj name="Test Prj"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;Level1 name="L101B"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;codes val="1" label="Temp 1" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;codes val="2" label="Temp 2" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;codes val="3" label="Temp 3" /&amp;gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;/prj&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some tags have up to 9 properties so I know a loop will do it but I can't figure out how to grab each lines of info.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example output Table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tag&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property1&amp;nbsp; Value1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property2 Value2&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;prj&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Test Prj"&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Level1&amp;nbsp; name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "L101B"&lt;/P&gt;&lt;P&gt;codes&amp;nbsp; val&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "1"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Temp 1"&lt;/P&gt;&lt;P&gt;codes&amp;nbsp; val&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "2"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Temp 2"&lt;/P&gt;&lt;P&gt;codes&amp;nbsp; val&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "3"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Temp 3"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Feb 2013 15:52:18 GMT</pubDate>
    <dc:creator>jerry898969</dc:creator>
    <dc:date>2013-02-14T15:52:18Z</dc:date>
    <item>
      <title>Pulling out tag info from xml file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pulling-out-tag-info-from-xml-file/m-p/109755#M30503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an xml file that was sent to me from an outside source.&amp;nbsp; What I need to do it parse it so I have all the tag and property info put into a table.&lt;/P&gt;&lt;P&gt;I have tried importing it as an xml file but the file isn't formatted correctly.&amp;nbsp; I have no say in how the file comes to me so I decided to import the file and pull the info out myself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is just a small example of some of the stuff within the file.&lt;/P&gt;&lt;P&gt;&amp;lt;prj name="Test Prj"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;Level1 name="L101B"&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;codes val="1" label="Temp 1" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;codes val="2" label="Temp 2" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;codes val="3" label="Temp 3" /&amp;gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;lt;/prj&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some tags have up to 9 properties so I know a loop will do it but I can't figure out how to grab each lines of info.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example output Table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tag&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property1&amp;nbsp; Value1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Property2 Value2&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;prj&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Test Prj"&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Level1&amp;nbsp; name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "L101B"&lt;/P&gt;&lt;P&gt;codes&amp;nbsp; val&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "1"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Temp 1"&lt;/P&gt;&lt;P&gt;codes&amp;nbsp; val&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "2"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Temp 2"&lt;/P&gt;&lt;P&gt;codes&amp;nbsp; val&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "3"&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Temp 3"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2013 15:52:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pulling-out-tag-info-from-xml-file/m-p/109755#M30503</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2013-02-14T15:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling out tag info from xml file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pulling-out-tag-info-from-xml-file/m-p/109756#M30504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; The XML Libname engine only works "out of the box" with very regular, non-hierarchical XML. Did you try turning your XML into a SAS dataset using the XML Mapper to map from XML "irregular" form to a SAS dataset?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; That might be worth a try. There is doc on how to use the XML Mapper and if you really get stumped, Tech Support can help. I'd try that road first before you parse this yourself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Why do you need to save the "container" tags like &amp;lt;prj&amp;gt; and &amp;lt;Level1&amp;gt;? It looks to me like the output structure would be a dataset with the name L101B and then it would have&lt;/P&gt;&lt;P&gt;code label&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp; Temp1&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Temp2&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp; Temp3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or else the DATASET would be named PRJ and there would be a variable named L101B in the dataset. In any case, if you created a long and skinny dataset, then you could transpose it quite easily.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Just a thought for an alternative approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2013 16:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pulling-out-tag-info-from-xml-file/m-p/109756#M30504</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2013-02-14T16:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling out tag info from xml file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pulling-out-tag-info-from-xml-file/m-p/109757#M30505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cynthia,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much for your reply.&amp;nbsp;&amp;nbsp;&amp;nbsp; I have to do this process in a sas program so I can't use the XML mapper.&lt;/P&gt;&lt;P&gt;What i'm trying to do is store this data in a sas dataset. &lt;/P&gt;&lt;P&gt;I have to have the output like the example I posted.&amp;nbsp; There is another process that takes this data set and uploads the data to a different database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't think the scan function is going to work for my situation.&amp;nbsp; There are some that have label="""TEMP 1""" and i'm not sure how to parse that out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any other help you can give me would be appreciated.&amp;nbsp; I want to eventually make it a macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Feb 2013 17:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pulling-out-tag-info-from-xml-file/m-p/109757#M30505</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2013-02-14T17:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling out tag info from xml file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pulling-out-tag-info-from-xml-file/m-p/109758#M30506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, you only build the XML map 1 time. Then, you could use it over and over. So the XML map is just a one-time step. but I'll have to think about it.....basically, you just want to strip out the tags???&lt;/P&gt;&lt;P&gt;Will there only be 1 Level tag? Or can you have multiple Level 1 tags???? Can you show an example of a tag that has 9 properties? Is it a code tag???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Feb 2013 02:10:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pulling-out-tag-info-from-xml-file/m-p/109758#M30506</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2013-02-15T02:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling out tag info from xml file</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Pulling-out-tag-info-from-xml-file/m-p/109759#M30507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cynthia,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&amp;nbsp; The issue has been resolved.&amp;nbsp; The data that was orginally sent to me was incorrect and they are working on correcting it and sending it in a different format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you once again for all your help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2013 15:03:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Pulling-out-tag-info-from-xml-file/m-p/109759#M30507</guid>
      <dc:creator>jerry898969</dc:creator>
      <dc:date>2013-02-22T15:03:40Z</dc:date>
    </item>
  </channel>
</rss>

