<?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: How to find a substring with variable numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856196#M338323</link>
    <description>&lt;P&gt;With apologies to Patrick for stealing his test data, perl expressions will do the job but can be difficult to understand - why not just use translate and the method your question suggests:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="johnagalloway0_1-1675071299166.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79911i38E49BFE26A7FE1F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="johnagalloway0_1-1675071299166.png" alt="johnagalloway0_1-1675071299166.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the character '#' may also appear in the string then just substitute another printable character - or even a non-printable character such as '00'x&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jan 2023 09:36:50 GMT</pubDate>
    <dc:creator>johnagalloway0</dc:creator>
    <dc:date>2023-01-30T09:36:50Z</dc:date>
    <item>
      <title>How to find a substring with variable numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856045#M338258</link>
      <description>&lt;P&gt;I would like to find the location of a substring of the form&amp;nbsp; &amp;nbsp;#.#Z, where the # sign represents any numeric digit.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, the substring might be 7.6Z or 1.3Z.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is possible that there may be other digits in the string overall, though this particular pattern will only be found once in the string.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 20:25:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856045#M338258</guid>
      <dc:creator>kz_</dc:creator>
      <dc:date>2023-01-27T20:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a substring with variable numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856054#M338260</link>
      <description>&lt;P&gt;Find the location of the Z, and then you know the location of the start of the substring as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where = find(string,'Z','i');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, that fails if a Z could appear prior to the digits.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 21:11:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856054#M338260</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-27T21:11:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a substring with variable numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856089#M338281</link>
      <description>&lt;P&gt;Assuming you then also want to extract this sub-string below one way to go.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
  input have_str :$40.;
  _prxid=prxparse('/\d+\.\d+Z/');
  want_startpos=prxmatch(_prxid,trim(have_str));
  call prxsubstr(_prxid, trim(have_str), _pos , _len);
  length want_str $10;
  want_str=substr(have_str,_pos,_len);

  /* or if you just want the number and Z could be upper or lowercase */
  _prxid2=prxparse('/\d+\.\d+(?=Z)/i');
  call prxsubstr(_prxid2, trim(have_str), _pos , _len);
  want_num=input(substr(have_str,_pos,_len), ?? best32.);
  datalines;
asdfasd78adsfad7.6Zdafad
adfadZ90Zadsf1.3Zsafd7890p0
adfadZ90Zadsf13Zsafd7890p0
;

proc print data=sample;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1674904989610.png" style="width: 547px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79893iA2F5F91AF6211ED3/image-dimensions/547x93?v=v2" width="547" height="93" role="button" title="Patrick_0-1674904989610.png" alt="Patrick_0-1674904989610.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Jan 2023 11:24:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856089#M338281</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-01-28T11:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a substring with variable numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856158#M338309</link>
      <description>&lt;P&gt;Can you post a working data step containing example data? That would make it easier to suggest working code. Showing the expected results would be useful, too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Jan 2023 20:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856158#M338309</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2023-01-29T20:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a substring with variable numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856196#M338323</link>
      <description>&lt;P&gt;With apologies to Patrick for stealing his test data, perl expressions will do the job but can be difficult to understand - why not just use translate and the method your question suggests:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="johnagalloway0_1-1675071299166.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79911i38E49BFE26A7FE1F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="johnagalloway0_1-1675071299166.png" alt="johnagalloway0_1-1675071299166.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the character '#' may also appear in the string then just substitute another printable character - or even a non-printable character such as '00'x&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jan 2023 09:36:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856196#M338323</guid>
      <dc:creator>johnagalloway0</dc:creator>
      <dc:date>2023-01-30T09:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to find a substring with variable numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856197#M338324</link>
      <description>apologies I misunderstood - the +3 finds the position of 'Z' - remove it (or change to +0) to get position of string</description>
      <pubDate>Mon, 30 Jan 2023 09:41:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-a-substring-with-variable-numbers/m-p/856197#M338324</guid>
      <dc:creator>johnagalloway0</dc:creator>
      <dc:date>2023-01-30T09:41:42Z</dc:date>
    </item>
  </channel>
</rss>

