<?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 numeric values in character in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Find-numeric-values-in-character/m-p/665808#M79005</link>
    <description>&lt;P&gt;HI &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/233875"&gt;@J_J_J&lt;/a&gt;&amp;nbsp; Please try-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input var $20.;
cards;
AB12345678
ABCD201642
20AB3413089000788913
20AB00000247287021
CD12345678
;

data want;
 set have;
 where lengthn(var)=10;
 if prxmatch('/^[a-z]{2}\d{8}/i', var);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 29 Jun 2020 14:53:07 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-06-29T14:53:07Z</dc:date>
    <item>
      <title>Find numeric values in character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-numeric-values-in-character/m-p/665805#M79004</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;I'm trying to find only those variables, where first 2 symbols are letters and next 8 are numbers and&amp;nbsp;length of variable is 10 digits. I used code:&amp;nbsp;(anyalpha(substr(CODE, 1, 2), 2) and anydigit(substr(CODE, 3, 10), &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; and length(CODE)=10). But it doesn't work. Please help to do it.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Have:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;AB12345678&lt;/P&gt;
&lt;P&gt;ABCD201642&lt;BR /&gt;20AB3413089000788913&lt;BR /&gt;20AB00000247287021&lt;/P&gt;
&lt;P&gt;CD12345678&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Want:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;AB12345678&lt;/P&gt;
&lt;P&gt;CD12345678&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 14:45:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-numeric-values-in-character/m-p/665805#M79004</guid>
      <dc:creator>J_J_J</dc:creator>
      <dc:date>2020-06-29T14:45:20Z</dc:date>
    </item>
    <item>
      <title>Re: Find numeric values in character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-numeric-values-in-character/m-p/665808#M79005</link>
      <description>&lt;P&gt;HI &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/233875"&gt;@J_J_J&lt;/a&gt;&amp;nbsp; Please try-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input var $20.;
cards;
AB12345678
ABCD201642
20AB3413089000788913
20AB00000247287021
CD12345678
;

data want;
 set have;
 where lengthn(var)=10;
 if prxmatch('/^[a-z]{2}\d{8}/i', var);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jun 2020 14:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-numeric-values-in-character/m-p/665808#M79005</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-06-29T14:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Find numeric values in character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-numeric-values-in-character/m-p/665876#M79007</link>
      <description>&lt;P&gt;Let's try using the ANYDIGIT and ANYALPHA functions to get the information needed for your test.&lt;/P&gt;
&lt;P&gt;First let's make some data.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input code $30. ;
cards;
AB12345678
ABCD201642
20AB3413089000788913
20AB00000247287021
CD12345678
XX1234 678
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now let's make some tests and then check that they follow all of the rules. Let's use NOTDIGIT to make sure the last 8 characters are all digits.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  len = lengthn(code);
  first_digit= anydigit(code);
  last_digit= anydigit(code,-len);
  last_nondigit=notdigit(code,-len);
  first_alpha=anyalpha(code);
  last_alpha=anyalpha(code,-len);
  want=len=10 and first_digit=3 and last_digit=10 and last_nondigit=2 and first_alpha=1 and last_alpha=2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;                                      first_    last_      last_     first_    last_
Obs    code                    len     digit    digit    nondigit     alpha    alpha    want

 1     AB12345678               10       3        10         2          1        2        1
 2     ABCD201642               10       5        10         4          1        4        0
 3     20AB3413089000788913     20       1        20         4          3        4        0
 4     20AB00000247287021       18       1        18         4          3        4        0
 5     CD12345678               10       3        10         2          1        2        1
 6     XX1234 678               10       3        10         7          1        2        0&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Jun 2020 18:02:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-numeric-values-in-character/m-p/665876#M79007</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-29T18:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: Find numeric values in character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-numeric-values-in-character/m-p/665989#M79009</link>
      <description>Thanks a lot, novinosrin!</description>
      <pubDate>Tue, 30 Jun 2020 04:45:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-numeric-values-in-character/m-p/665989#M79009</guid>
      <dc:creator>J_J_J</dc:creator>
      <dc:date>2020-06-30T04:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: Find numeric values in character</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Find-numeric-values-in-character/m-p/665990#M79010</link>
      <description>Thanks, Tom. Your solution seems good too.</description>
      <pubDate>Tue, 30 Jun 2020 04:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Find-numeric-values-in-character/m-p/665990#M79010</guid>
      <dc:creator>J_J_J</dc:creator>
      <dc:date>2020-06-30T04:46:55Z</dc:date>
    </item>
  </channel>
</rss>

