<?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: Find and select unknown name in XML based character field in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/413985#M101391</link>
    <description>&lt;P&gt;HI Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your answer, unfortunatley i dont know the name, so i cant work out the lenght.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried using scan to select individual words from&amp;nbsp;the name, but i also dont know the naming format (first name, last name or last name, middle name, first name, second name, or any combination), which then gives me problems when i try to re-combine the words...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;paul&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 16 Nov 2017 13:23:51 GMT</pubDate>
    <dc:creator>pandhandj</dc:creator>
    <dc:date>2017-11-16T13:23:51Z</dc:date>
    <item>
      <title>Find and select unknown name in XML based character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/413967#M101384</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am stuck (again) and could do with some help please.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a character variable&amp;nbsp;which is taken from an XML file. &amp;nbsp;Within this&amp;nbsp;variableis a name, i dont know what the is, or where it is located within th variable. &amp;nbsp;I nned to select the name and then place it into a new variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is an edited example of the variable (to remove any propietry data) -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;...2001/XMLSchema"&amp;gt;&amp;lt;Test&amp;gt;&amp;lt;Overall&amp;gt;98&amp;lt;/Overall&amp;gt;&amp;lt;Score&amp;gt;98&amp;lt;/Score&amp;gt;&amp;lt;Source&amp;gt;Data&amp;lt;/Source&amp;gt;&amp;lt;Data&amp;gt;TRUMP, DONALD&amp;amp;lt;br/&amp;amp;gt;19xx-xx-xx&amp;amp;lt;br/&amp;amp;gt;&amp;amp;lt;br/&amp;amp;gt;&amp;amp;lt;br/&amp;amp;gt;&amp;lt;/Data&amp;gt;&amp;lt;Cause&amp;gt;&amp;amp;lt;a href="http://...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the name is always marked by &amp;lt;Data&amp;gt; (only instance in variable) and is always ended by the "&lt;SPAN&gt;&amp;amp;lt;br/&amp;amp;gt" marker (there are more instances of this marker later in the field).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have been using the code below, it can select the name, but i cant get it to stop selecting after the name, so i end up with all the XML stuff after the name.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can anyone point me in the right direction?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thanks in advance,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;paul&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data want;&lt;BR /&gt;set have;&lt;BR /&gt;iname = index(var,'&amp;lt;Data&amp;gt;');&lt;BR /&gt;name = substr(var, iname + 6, '&amp;amp;lt;br/&amp;amp;gt');&lt;BR /&gt;drop iname;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 12:11:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/413967#M101384</guid>
      <dc:creator>pandhandj</dc:creator>
      <dc:date>2017-11-16T12:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Find and select unknown name in XML based character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/413969#M101385</link>
      <description>&lt;P&gt;The third argument to substr() (the length) needs to be a number, so you must calculate that by subtracting the position of the first character of the name from the position of &lt;SPAN&gt;'&amp;amp;lt;br/&amp;amp;gt'&lt;/SPAN&gt; in your string.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 12:24:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/413969#M101385</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-16T12:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: Find and select unknown name in XML based character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/413985#M101391</link>
      <description>&lt;P&gt;HI Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for your answer, unfortunatley i dont know the name, so i cant work out the lenght.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried using scan to select individual words from&amp;nbsp;the name, but i also dont know the naming format (first name, last name or last name, middle name, first name, second name, or any combination), which then gives me problems when i try to re-combine the words...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;paul&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 13:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/413985#M101391</guid>
      <dc:creator>pandhandj</dc:creator>
      <dc:date>2017-11-16T13:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: Find and select unknown name in XML based character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/413988#M101394</link>
      <description>&lt;P&gt;HI Kurt,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have just worked out what you mean!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the start position of the name,&amp;nbsp;so if i work out the position of the &amp;amp; and then substr from start to the &amp;amp;, i will be left with the name?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will give that a try,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;paul&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 13:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/413988#M101394</guid>
      <dc:creator>pandhandj</dc:creator>
      <dc:date>2017-11-16T13:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Find and select unknown name in XML based character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/414002#M101399</link>
      <description>&lt;P&gt;A quick example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
x1 = '&amp;lt;Source&amp;gt;Data&amp;lt;/Source&amp;gt;&amp;lt;Data&amp;gt;TRUMP, DONALD&amp;amp;lt;br/&amp;amp;gt;19xx-xx-xx&amp;amp;lt;br/&amp;amp;gt;&amp;amp;lt;br/&amp;amp;gt;&amp;amp;lt;br/&amp;amp;gt;&amp;lt;/Data&amp;gt;';
begin = index(x1,'&amp;lt;Data&amp;gt;')+6;
end = index(x1,'&amp;amp;lt;br/&amp;amp;gt;');
x2 = substr(x1,begin,end - begin);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the reference string for the end&lt;/P&gt;
&lt;PRE&gt;&amp;amp;lt;br/&amp;amp;gt;&lt;/PRE&gt;
&lt;P&gt;appears anywhere before the reference string for the beginning&lt;/P&gt;
&lt;PRE&gt;&amp;lt;Data&amp;gt;&lt;/PRE&gt;
&lt;P&gt;you will have to substr x1 first so that it actually starts at "begin".&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 14:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/414002#M101399</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-16T14:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Find and select unknown name in XML based character field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/414066#M101420</link>
      <description>&lt;P&gt;Hi Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have got it going &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we ever meet up, a few glasses of your favourite tipple are on me!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;all the best,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;paul&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 16:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-and-select-unknown-name-in-XML-based-character-field/m-p/414066#M101420</guid>
      <dc:creator>pandhandj</dc:creator>
      <dc:date>2017-11-16T16:06:56Z</dc:date>
    </item>
  </channel>
</rss>

