<?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 Re: Pulling all Namespaces from XML in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Pulling-all-Namespaces-from-XML/m-p/340252#M77745</link>
    <description>&lt;P&gt;In your example each line is a set of space-separated words.&amp;nbsp; The last word of each is "/&amp;gt;" and you apparently want a part of the next-to-last word, namely the part to the left of the = sign.&amp;nbsp; You also want an output record with type='ID' for each incoming record number, regardless of content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code is not "xml-aware" in any way, but it does the particular task as you have described it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=record type);
  input record xmltext &amp;amp;$80.;
  length type $20;

  type='ID'; output;

  next_to_last_word=scan(xmltext,-2,' ');
  type=scan(next_to_last_word,1,'=');
  output;
datalines;
1 &amp;lt;keyData siteId="1" id="" lastName="Caser" /&amp;gt;
2 &amp;lt;keyData siteId="1" email="do_08@awef.com" /&amp;gt;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 12 Mar 2017 19:09:48 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-03-12T19:09:48Z</dc:date>
    <item>
      <title>Pulling all Namespaces from XML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-all-Namespaces-from-XML/m-p/340211#M77729</link>
      <description>&lt;P&gt;I want to be able to see if the types of data we are sending changes over time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a series of records with a range of namespaces that are sent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have&lt;/P&gt;&lt;P&gt;Record XMLData&lt;/P&gt;&lt;P&gt;1 &amp;lt;keyData siteId="1" id="" lastName="Caser" /&amp;gt;&lt;/P&gt;&lt;P&gt;2 &amp;lt;keyData siteId="1" email="do_08@awef.com" /&amp;gt;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Want&lt;/P&gt;&lt;P&gt;Record Type&lt;/P&gt;&lt;P&gt;1 ID&lt;/P&gt;&lt;P&gt;1 lastName&lt;/P&gt;&lt;P&gt;2 ID&lt;/P&gt;&lt;P&gt;2 email&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sometimes I'll have ID, sometimes I'll have ID, Email, and SSN -- it varies by the record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have experience trying to shred out XML using SAS?&lt;/P&gt;</description>
      <pubDate>Sun, 12 Mar 2017 03:23:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-all-Namespaces-from-XML/m-p/340211#M77729</guid>
      <dc:creator>JS</dc:creator>
      <dc:date>2017-03-12T03:23:20Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling all Namespaces from XML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-all-Namespaces-from-XML/m-p/340215#M77730</link>
      <description>&lt;P&gt;The XML libname doesn't work for you?&lt;/P&gt;
&lt;P&gt;Or XML Mapper?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/engxml/64990/HTML/default/viewer.htm#titlepage.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/engxml/64990/HTML/default/viewer.htm#titlepage.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Mar 2017 04:26:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-all-Namespaces-from-XML/m-p/340215#M77730</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-03-12T04:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling all Namespaces from XML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-all-Namespaces-from-XML/m-p/340224#M77736</link>
      <description>&lt;PRE&gt;
Post some more data or example XML file would be better .


&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Mar 2017 10:12:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-all-Namespaces-from-XML/m-p/340224#M77736</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-12T10:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling all Namespaces from XML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-all-Namespaces-from-XML/m-p/340227#M77738</link>
      <description>&lt;PRE&gt;


data have;
input Record XMLData $50.;
cards;
1 &lt;KEYDATA siteid="1" id="" lastname="Caser"&gt;&lt;/KEYDATA&gt;
2 &lt;KEYDATA siteid="1" email="do_08@awef.com"&gt;&lt;/KEYDATA&gt;
;
run;

data want;
 set have;
 pid=prxparse('/\w+(?==")/o');
 s=1;e=length(xmldata);
 call prxnext(pid,s,e,xmldata,p,l);
 do while(p gt 0);
  type=substr(xmldata,p,l);output;
  call prxnext(pid,s,e,xmldata,p,l);
 end;
 drop pid s e p l;
run;


&lt;/PRE&gt;</description>
      <pubDate>Sun, 12 Mar 2017 10:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-all-Namespaces-from-XML/m-p/340227#M77738</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-12T10:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Pulling all Namespaces from XML</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Pulling-all-Namespaces-from-XML/m-p/340252#M77745</link>
      <description>&lt;P&gt;In your example each line is a set of space-separated words.&amp;nbsp; The last word of each is "/&amp;gt;" and you apparently want a part of the next-to-last word, namely the part to the left of the = sign.&amp;nbsp; You also want an output record with type='ID' for each incoming record number, regardless of content.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code is not "xml-aware" in any way, but it does the particular task as you have described it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want (keep=record type);
  input record xmltext &amp;amp;$80.;
  length type $20;

  type='ID'; output;

  next_to_last_word=scan(xmltext,-2,' ');
  type=scan(next_to_last_word,1,'=');
  output;
datalines;
1 &amp;lt;keyData siteId="1" id="" lastName="Caser" /&amp;gt;
2 &amp;lt;keyData siteId="1" email="do_08@awef.com" /&amp;gt;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Mar 2017 19:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Pulling-all-Namespaces-from-XML/m-p/340252#M77745</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-03-12T19:09:48Z</dc:date>
    </item>
  </channel>
</rss>

