<?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: Extract within a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-within-a-string/m-p/282640#M57468</link>
    <description>&lt;P&gt;Excellent thanks for the reply!&lt;/P&gt;</description>
    <pubDate>Thu, 07 Jul 2016 09:16:29 GMT</pubDate>
    <dc:creator>LK357</dc:creator>
    <dc:date>2016-07-07T09:16:29Z</dc:date>
    <item>
      <title>Extract within a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-within-a-string/m-p/280726#M57177</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am tring to extract the number following the id= from within this string below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.blahblah/blahblah/confirmation?id=1234567&amp;amp;media=12345" target="_blank"&gt;http://www.blahblah/blahblah/confirmation?id=1234567&amp;amp;media=12345&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 11:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-within-a-string/m-p/280726#M57177</guid>
      <dc:creator>LK357</dc:creator>
      <dc:date>2016-06-28T11:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extract within a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-within-a-string/m-p/281763#M57178</link>
      <description>&lt;P&gt;There are several ways depending on consistency of your input stream.&lt;/P&gt;
&lt;P&gt;Here are two.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   string='http://www.blahblah/blahblah/confirmation?id=1234567&amp;amp;media=12345';
   /* if the ID ALWAYS appears in the same place*/
   oneway= scan(string,2,'=&amp;amp;');
   /* or if ID may appear in other locations*/
   /*find position of id=*/
   pos1 = index(string,'id=');
   /* find position of &amp;amp; AFTER the first position*/
   pos2= find(string,'&amp;amp;',pos1);
   otherway = substr(string,pos1+3,pos2-(pos1+3));
   /* not if your target string value exceeds 8 characters you should declare a length
   prior to use*/

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the value needs to be actually numeric then you could use an INPUT such as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;oneway = input(scan(string,2,'=&amp;amp;'),best16.);&lt;/P&gt;
&lt;P&gt;But if there were any values not numeric such as id=123ABC456 that would fail.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2016 16:42:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-within-a-string/m-p/281763#M57178</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-07-01T16:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract within a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-within-a-string/m-p/282640#M57468</link>
      <description>&lt;P&gt;Excellent thanks for the reply!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jul 2016 09:16:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-within-a-string/m-p/282640#M57468</guid>
      <dc:creator>LK357</dc:creator>
      <dc:date>2016-07-07T09:16:29Z</dc:date>
    </item>
  </channel>
</rss>

