<?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 Find position of substring in a string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Find-position-of-substring-in-a-string/m-p/555441#M154572</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the below dataset I have 2 columns c and y with data as follows:&lt;/P&gt;&lt;P&gt;X&lt;/P&gt;&lt;P&gt;34&amp;nbsp; 45 th avenue&lt;/P&gt;&lt;P&gt;South west 34 street&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column y&amp;nbsp;&lt;/P&gt;&lt;P&gt;th avenue&lt;/P&gt;&lt;P&gt;street&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So using column y I need to look in column x and if the 1stword is th in y and pattern matches in xthen I need to pull&lt;/P&gt;&lt;P&gt;&amp;nbsp;The preceding digit&amp;nbsp;&lt;/P&gt;&lt;P&gt;So my final output z would be something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column y&amp;nbsp;&lt;/P&gt;&lt;P&gt;45 th avenue&lt;/P&gt;&lt;P&gt;street&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rohit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 May 2019 18:41:47 GMT</pubDate>
    <dc:creator>Rohit_1990</dc:creator>
    <dc:date>2019-05-01T18:41:47Z</dc:date>
    <item>
      <title>Find position of substring in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-position-of-substring-in-a-string/m-p/555441#M154572</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the below dataset I have 2 columns c and y with data as follows:&lt;/P&gt;&lt;P&gt;X&lt;/P&gt;&lt;P&gt;34&amp;nbsp; 45 th avenue&lt;/P&gt;&lt;P&gt;South west 34 street&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column y&amp;nbsp;&lt;/P&gt;&lt;P&gt;th avenue&lt;/P&gt;&lt;P&gt;street&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So using column y I need to look in column x and if the 1stword is th in y and pattern matches in xthen I need to pull&lt;/P&gt;&lt;P&gt;&amp;nbsp;The preceding digit&amp;nbsp;&lt;/P&gt;&lt;P&gt;So my final output z would be something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column y&amp;nbsp;&lt;/P&gt;&lt;P&gt;45 th avenue&lt;/P&gt;&lt;P&gt;street&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rohit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 18:41:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-position-of-substring-in-a-string/m-p/555441#M154572</guid>
      <dc:creator>Rohit_1990</dc:creator>
      <dc:date>2019-05-01T18:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Find position of substring in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-position-of-substring-in-a-string/m-p/555461#M154580</link>
      <description>&lt;P&gt;Something like the following should work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have (drop=position length);
  informat x y $30.;
  input x &amp;amp; y &amp;amp;;
  if scan(y,1) eq 'th' then do;
    call scan(x, FINDW(x, 'th',' ', 'e')-1, position, length);
    z=substr(x,position);
  end;
  else z=y;
  cards;
34 45 th avenue  th avenue
South west 34 street  street
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 19:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-position-of-substring-in-a-string/m-p/555461#M154580</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2019-05-01T19:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: Find position of substring in a string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Find-position-of-substring-in-a-string/m-p/555510#M154602</link>
      <description>&lt;P&gt;Why don't you keep the street number in your example?&lt;/P&gt;
&lt;P&gt;What do you do if there is no match?&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 23:16:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Find-position-of-substring-in-a-string/m-p/555510#M154602</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-05-01T23:16:53Z</dc:date>
    </item>
  </channel>
</rss>

